HTTP login form is messed up on IOS Ionic 3 but works on Android












0














I'm building a login form which is sending the data to the HTTP login service.
It's working very well on Android devices but on IOS it tells me that email, password, and device_id is required so the HTTP request is don't but not sending form data while it's successful in Android with a status code of 200.
Does anybody have any idea why this is happening?



Login Function:



onLogin(form: NgForm) {
console.log('login for is: ', { email: "bexel@edigits.net", password:
"Karem@123", device_id: "123" });
this.userService.login(this.login).then(res => {
if (res.status = 200) {
console.log(res);
if (res.data.user.admin_id) {
this.storage.set('admin_id', res.data.user.admin_id);
}
this.storage.set('token', res.data.token);
this.storage.set('device_id', this.device.uuid);
this.storage.set('name', res.data.user.name);
this.storage.set('account_id', res.data.user._id);
this.storage.set('picture', res.data.user_picture);
this.navCtrl.setRoot(StatsPage);
}
console.log('stored keys', this.storage.keys());
this.onDisplayToaster('this is our login response '+ res.status);
}).catch(e => {
console.error(e);
console.log(form.value);
});
}


User Service Login Function:



login(obj: any) {
return this.apiService.post('login', obj);
}


Api Service:



@Injectable()
export class WebApiService {
errorMessage: string;
headers = {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'POST, GET, OPTIONS, PUT',
'Content-Type': 'application/json',
'Accept': 'application/json'
}
constructor(
private http: HttpClient,
private httpService: HTTP,
private toastCtrl: ToastController
) { }
private formatErrors(error: any) {
return Observable.throw(error);
}
get(path: string, params?: HttpParams) {
return this.httpService.get(`${environment.api_url}${path}`, params,
this.headers)
.then(res => {
JSON.parse(res.data);
console.log('this is the res', res.data);
return JSON.parse(res.data);
}).catch(e => { console.error(this.formatErrors(e)); });
}
post(path: string, body: Object = {}) {
return this.httpService.post(`${environment.api_url}${path}`, body,
this.headers)
.then(res => {
JSON.parse(res.data);
console.log('this is the res', JSON.parse(res.data));
return JSON.parse(res.data);
}).catch(e => { console.error(this.formatErrors(e)); });
}
}


Console Log:



2018-11-12 08:14:15.834137+0200 bexelApp[1115:17895] ERROR: {"_isScalar":false,"error":{"status":401,"headers":{"server":"Apache/2.4.18 (Ubuntu)","content-type":"application/json","connection":"Keep-Alive","date":"Mon, 12 Nov 2018 06:14:15 GMT","content-length":"125","keep-alive":"timeout=5, max=100","cache-control":"no-cache"},"url":"http://198.211.125.43/bexelapi/mobapi/login","error":"{"message":{"email":["The field is required."],"password":["The field is required."],"device_id":["The field is required."]}}"}}
2018-11-12 08:14:15.843486+0200 bexelApp[1115:17895] ERROR: {"__zone_symbol__currentTask":{"type":"microTask","state":"notScheduled","source":"Promise.then","zone":"angular","cancelFn":null,"runCount":0},"line":443,"column":20,"sourceURL":"http://localhost:8080/build/main.js"}


The function is working on Androidd but not IOS, note that i tried to enter login data as static to make sure that login credentials is right but with the same result.



I tried updating HTTP Native plugin with the same result.










share|improve this question
























  • Could you add the code of your userService.login function ?
    – saperlipopette
    Nov 12 at 10:46










  • updated @saperlipopette
    – Mohamed Wahshey
    Nov 12 at 10:52










  • there is no error with the function, it's working very well, but data is not sent in IOS while in Android it works @saperlipopette
    – Mohamed Wahshey
    Nov 12 at 10:53










  • Connect your phone to your computer in USB, run your app, and then inspect your app with Safari Inspector (You will have a javascript console with a network tab to see all the outgoing requests). Maybe you could get more details on what's wrong by using this tool, because your code seems correct
    – saperlipopette
    Nov 12 at 10:56










  • @saperlipopette i updated with the console log
    – Mohamed Wahshey
    Nov 12 at 11:07
















0














I'm building a login form which is sending the data to the HTTP login service.
It's working very well on Android devices but on IOS it tells me that email, password, and device_id is required so the HTTP request is don't but not sending form data while it's successful in Android with a status code of 200.
Does anybody have any idea why this is happening?



Login Function:



onLogin(form: NgForm) {
console.log('login for is: ', { email: "bexel@edigits.net", password:
"Karem@123", device_id: "123" });
this.userService.login(this.login).then(res => {
if (res.status = 200) {
console.log(res);
if (res.data.user.admin_id) {
this.storage.set('admin_id', res.data.user.admin_id);
}
this.storage.set('token', res.data.token);
this.storage.set('device_id', this.device.uuid);
this.storage.set('name', res.data.user.name);
this.storage.set('account_id', res.data.user._id);
this.storage.set('picture', res.data.user_picture);
this.navCtrl.setRoot(StatsPage);
}
console.log('stored keys', this.storage.keys());
this.onDisplayToaster('this is our login response '+ res.status);
}).catch(e => {
console.error(e);
console.log(form.value);
});
}


User Service Login Function:



login(obj: any) {
return this.apiService.post('login', obj);
}


Api Service:



@Injectable()
export class WebApiService {
errorMessage: string;
headers = {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'POST, GET, OPTIONS, PUT',
'Content-Type': 'application/json',
'Accept': 'application/json'
}
constructor(
private http: HttpClient,
private httpService: HTTP,
private toastCtrl: ToastController
) { }
private formatErrors(error: any) {
return Observable.throw(error);
}
get(path: string, params?: HttpParams) {
return this.httpService.get(`${environment.api_url}${path}`, params,
this.headers)
.then(res => {
JSON.parse(res.data);
console.log('this is the res', res.data);
return JSON.parse(res.data);
}).catch(e => { console.error(this.formatErrors(e)); });
}
post(path: string, body: Object = {}) {
return this.httpService.post(`${environment.api_url}${path}`, body,
this.headers)
.then(res => {
JSON.parse(res.data);
console.log('this is the res', JSON.parse(res.data));
return JSON.parse(res.data);
}).catch(e => { console.error(this.formatErrors(e)); });
}
}


Console Log:



2018-11-12 08:14:15.834137+0200 bexelApp[1115:17895] ERROR: {"_isScalar":false,"error":{"status":401,"headers":{"server":"Apache/2.4.18 (Ubuntu)","content-type":"application/json","connection":"Keep-Alive","date":"Mon, 12 Nov 2018 06:14:15 GMT","content-length":"125","keep-alive":"timeout=5, max=100","cache-control":"no-cache"},"url":"http://198.211.125.43/bexelapi/mobapi/login","error":"{"message":{"email":["The field is required."],"password":["The field is required."],"device_id":["The field is required."]}}"}}
2018-11-12 08:14:15.843486+0200 bexelApp[1115:17895] ERROR: {"__zone_symbol__currentTask":{"type":"microTask","state":"notScheduled","source":"Promise.then","zone":"angular","cancelFn":null,"runCount":0},"line":443,"column":20,"sourceURL":"http://localhost:8080/build/main.js"}


The function is working on Androidd but not IOS, note that i tried to enter login data as static to make sure that login credentials is right but with the same result.



I tried updating HTTP Native plugin with the same result.










share|improve this question
























  • Could you add the code of your userService.login function ?
    – saperlipopette
    Nov 12 at 10:46










  • updated @saperlipopette
    – Mohamed Wahshey
    Nov 12 at 10:52










  • there is no error with the function, it's working very well, but data is not sent in IOS while in Android it works @saperlipopette
    – Mohamed Wahshey
    Nov 12 at 10:53










  • Connect your phone to your computer in USB, run your app, and then inspect your app with Safari Inspector (You will have a javascript console with a network tab to see all the outgoing requests). Maybe you could get more details on what's wrong by using this tool, because your code seems correct
    – saperlipopette
    Nov 12 at 10:56










  • @saperlipopette i updated with the console log
    – Mohamed Wahshey
    Nov 12 at 11:07














0












0








0







I'm building a login form which is sending the data to the HTTP login service.
It's working very well on Android devices but on IOS it tells me that email, password, and device_id is required so the HTTP request is don't but not sending form data while it's successful in Android with a status code of 200.
Does anybody have any idea why this is happening?



Login Function:



onLogin(form: NgForm) {
console.log('login for is: ', { email: "bexel@edigits.net", password:
"Karem@123", device_id: "123" });
this.userService.login(this.login).then(res => {
if (res.status = 200) {
console.log(res);
if (res.data.user.admin_id) {
this.storage.set('admin_id', res.data.user.admin_id);
}
this.storage.set('token', res.data.token);
this.storage.set('device_id', this.device.uuid);
this.storage.set('name', res.data.user.name);
this.storage.set('account_id', res.data.user._id);
this.storage.set('picture', res.data.user_picture);
this.navCtrl.setRoot(StatsPage);
}
console.log('stored keys', this.storage.keys());
this.onDisplayToaster('this is our login response '+ res.status);
}).catch(e => {
console.error(e);
console.log(form.value);
});
}


User Service Login Function:



login(obj: any) {
return this.apiService.post('login', obj);
}


Api Service:



@Injectable()
export class WebApiService {
errorMessage: string;
headers = {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'POST, GET, OPTIONS, PUT',
'Content-Type': 'application/json',
'Accept': 'application/json'
}
constructor(
private http: HttpClient,
private httpService: HTTP,
private toastCtrl: ToastController
) { }
private formatErrors(error: any) {
return Observable.throw(error);
}
get(path: string, params?: HttpParams) {
return this.httpService.get(`${environment.api_url}${path}`, params,
this.headers)
.then(res => {
JSON.parse(res.data);
console.log('this is the res', res.data);
return JSON.parse(res.data);
}).catch(e => { console.error(this.formatErrors(e)); });
}
post(path: string, body: Object = {}) {
return this.httpService.post(`${environment.api_url}${path}`, body,
this.headers)
.then(res => {
JSON.parse(res.data);
console.log('this is the res', JSON.parse(res.data));
return JSON.parse(res.data);
}).catch(e => { console.error(this.formatErrors(e)); });
}
}


Console Log:



2018-11-12 08:14:15.834137+0200 bexelApp[1115:17895] ERROR: {"_isScalar":false,"error":{"status":401,"headers":{"server":"Apache/2.4.18 (Ubuntu)","content-type":"application/json","connection":"Keep-Alive","date":"Mon, 12 Nov 2018 06:14:15 GMT","content-length":"125","keep-alive":"timeout=5, max=100","cache-control":"no-cache"},"url":"http://198.211.125.43/bexelapi/mobapi/login","error":"{"message":{"email":["The field is required."],"password":["The field is required."],"device_id":["The field is required."]}}"}}
2018-11-12 08:14:15.843486+0200 bexelApp[1115:17895] ERROR: {"__zone_symbol__currentTask":{"type":"microTask","state":"notScheduled","source":"Promise.then","zone":"angular","cancelFn":null,"runCount":0},"line":443,"column":20,"sourceURL":"http://localhost:8080/build/main.js"}


The function is working on Androidd but not IOS, note that i tried to enter login data as static to make sure that login credentials is right but with the same result.



I tried updating HTTP Native plugin with the same result.










share|improve this question















I'm building a login form which is sending the data to the HTTP login service.
It's working very well on Android devices but on IOS it tells me that email, password, and device_id is required so the HTTP request is don't but not sending form data while it's successful in Android with a status code of 200.
Does anybody have any idea why this is happening?



Login Function:



onLogin(form: NgForm) {
console.log('login for is: ', { email: "bexel@edigits.net", password:
"Karem@123", device_id: "123" });
this.userService.login(this.login).then(res => {
if (res.status = 200) {
console.log(res);
if (res.data.user.admin_id) {
this.storage.set('admin_id', res.data.user.admin_id);
}
this.storage.set('token', res.data.token);
this.storage.set('device_id', this.device.uuid);
this.storage.set('name', res.data.user.name);
this.storage.set('account_id', res.data.user._id);
this.storage.set('picture', res.data.user_picture);
this.navCtrl.setRoot(StatsPage);
}
console.log('stored keys', this.storage.keys());
this.onDisplayToaster('this is our login response '+ res.status);
}).catch(e => {
console.error(e);
console.log(form.value);
});
}


User Service Login Function:



login(obj: any) {
return this.apiService.post('login', obj);
}


Api Service:



@Injectable()
export class WebApiService {
errorMessage: string;
headers = {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'POST, GET, OPTIONS, PUT',
'Content-Type': 'application/json',
'Accept': 'application/json'
}
constructor(
private http: HttpClient,
private httpService: HTTP,
private toastCtrl: ToastController
) { }
private formatErrors(error: any) {
return Observable.throw(error);
}
get(path: string, params?: HttpParams) {
return this.httpService.get(`${environment.api_url}${path}`, params,
this.headers)
.then(res => {
JSON.parse(res.data);
console.log('this is the res', res.data);
return JSON.parse(res.data);
}).catch(e => { console.error(this.formatErrors(e)); });
}
post(path: string, body: Object = {}) {
return this.httpService.post(`${environment.api_url}${path}`, body,
this.headers)
.then(res => {
JSON.parse(res.data);
console.log('this is the res', JSON.parse(res.data));
return JSON.parse(res.data);
}).catch(e => { console.error(this.formatErrors(e)); });
}
}


Console Log:



2018-11-12 08:14:15.834137+0200 bexelApp[1115:17895] ERROR: {"_isScalar":false,"error":{"status":401,"headers":{"server":"Apache/2.4.18 (Ubuntu)","content-type":"application/json","connection":"Keep-Alive","date":"Mon, 12 Nov 2018 06:14:15 GMT","content-length":"125","keep-alive":"timeout=5, max=100","cache-control":"no-cache"},"url":"http://198.211.125.43/bexelapi/mobapi/login","error":"{"message":{"email":["The field is required."],"password":["The field is required."],"device_id":["The field is required."]}}"}}
2018-11-12 08:14:15.843486+0200 bexelApp[1115:17895] ERROR: {"__zone_symbol__currentTask":{"type":"microTask","state":"notScheduled","source":"Promise.then","zone":"angular","cancelFn":null,"runCount":0},"line":443,"column":20,"sourceURL":"http://localhost:8080/build/main.js"}


The function is working on Androidd but not IOS, note that i tried to enter login data as static to make sure that login credentials is right but with the same result.



I tried updating HTTP Native plugin with the same result.







angular forms http login ionic3






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 at 11:44









Suraj Rao

22.6k75469




22.6k75469










asked Nov 12 at 10:27









Mohamed Wahshey

137211




137211












  • Could you add the code of your userService.login function ?
    – saperlipopette
    Nov 12 at 10:46










  • updated @saperlipopette
    – Mohamed Wahshey
    Nov 12 at 10:52










  • there is no error with the function, it's working very well, but data is not sent in IOS while in Android it works @saperlipopette
    – Mohamed Wahshey
    Nov 12 at 10:53










  • Connect your phone to your computer in USB, run your app, and then inspect your app with Safari Inspector (You will have a javascript console with a network tab to see all the outgoing requests). Maybe you could get more details on what's wrong by using this tool, because your code seems correct
    – saperlipopette
    Nov 12 at 10:56










  • @saperlipopette i updated with the console log
    – Mohamed Wahshey
    Nov 12 at 11:07


















  • Could you add the code of your userService.login function ?
    – saperlipopette
    Nov 12 at 10:46










  • updated @saperlipopette
    – Mohamed Wahshey
    Nov 12 at 10:52










  • there is no error with the function, it's working very well, but data is not sent in IOS while in Android it works @saperlipopette
    – Mohamed Wahshey
    Nov 12 at 10:53










  • Connect your phone to your computer in USB, run your app, and then inspect your app with Safari Inspector (You will have a javascript console with a network tab to see all the outgoing requests). Maybe you could get more details on what's wrong by using this tool, because your code seems correct
    – saperlipopette
    Nov 12 at 10:56










  • @saperlipopette i updated with the console log
    – Mohamed Wahshey
    Nov 12 at 11:07
















Could you add the code of your userService.login function ?
– saperlipopette
Nov 12 at 10:46




Could you add the code of your userService.login function ?
– saperlipopette
Nov 12 at 10:46












updated @saperlipopette
– Mohamed Wahshey
Nov 12 at 10:52




updated @saperlipopette
– Mohamed Wahshey
Nov 12 at 10:52












there is no error with the function, it's working very well, but data is not sent in IOS while in Android it works @saperlipopette
– Mohamed Wahshey
Nov 12 at 10:53




there is no error with the function, it's working very well, but data is not sent in IOS while in Android it works @saperlipopette
– Mohamed Wahshey
Nov 12 at 10:53












Connect your phone to your computer in USB, run your app, and then inspect your app with Safari Inspector (You will have a javascript console with a network tab to see all the outgoing requests). Maybe you could get more details on what's wrong by using this tool, because your code seems correct
– saperlipopette
Nov 12 at 10:56




Connect your phone to your computer in USB, run your app, and then inspect your app with Safari Inspector (You will have a javascript console with a network tab to see all the outgoing requests). Maybe you could get more details on what's wrong by using this tool, because your code seems correct
– saperlipopette
Nov 12 at 10:56












@saperlipopette i updated with the console log
– Mohamed Wahshey
Nov 12 at 11:07




@saperlipopette i updated with the console log
– Mohamed Wahshey
Nov 12 at 11:07

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53260225%2fhttp-login-form-is-messed-up-on-ios-ionic-3-but-works-on-android%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53260225%2fhttp-login-form-is-messed-up-on-ios-ionic-3-but-works-on-android%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Florida Star v. B. J. F.

Error while running script in elastic search , gateway timeout

Adding quotations to stringified JSON object values