In my ionic app I have a POST request to do login. This works fine on an iPhone but when I test the app on an Android phone the server returns a 404 Not Found error.
My code for making the HTTP request looks like this:
loginUser: function(email,password) { var em = email.replace(/\\s/g,''); var pw = password.replace(/\\s/g,''); var url = apiDomain + '/api/v1/user/login/'; if (em && pw) { return $http.post(url, { auth: { email: em, password: pw } }).then(function successCallback(response) { alert('login success. response = '+JSON.stringify(response)); return response; }, function errorCallback(response) { alert('login fail. response = '+JSON.stringify(response)); return -1; }); } },
Can anyone think of a reason why this would work on an iPhone but not on an Android phone?
The text shown by the alert() in the errorCallback is:
login fail. response = { "data":"", "status":404, "config":{ "method":"POST", "transformRequest":[null], "url":"http://cues-server-dev.elasticbeanstalk.com/api/v1/user/login/", "data":{ "auth":"{ "email":"aa@aa.aa", "password":"alcohol"}}, "headers":{ "Accept":"application/json,text,plain,*/*", "Content-Type":"application/json;charset=utf-8"}}, "statusText":"Not Found"}
I am at a loss to understand why this works on an iPhone but not an Android phone.
It may be to do with the URL prefix. Have you tried using:
apiDomain = @"https://cues-server-dev.elasticbeanstalk.com"
or
apiDomain = @"http://www.cues-server-dev.elasticbeanstalk.com"
or some other variant.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.