【发布时间】:2015-10-26 11:29:27
【问题描述】:
在我的 ionic 应用程序中,我有一个 POST 请求进行登录。这在 iPhone 上运行良好,但当我在 Android 手机上测试应用程序时,服务器返回 404 Not Found 错误。
我发出 HTTP 请求的代码如下所示:
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;
});
}
},
谁能想到为什么这可以在 iPhone 上运行但不能在 Android 手机上运行?
errorCallback中的alert()显示的文字是:
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"}
我不明白为什么这适用于 iPhone 而不是 Android 手机。
【问题讨论】:
-
* 初始检查是否授予互联网权限。
-
Android 手机上的所有其他应用程序都可以正常使用互联网。
-
* 需要对您遇到问题的 Android-App 具有 Internet 权限。所有其他应用程序都拥有互联网权限并不重要。
-
是的,它确实有互联网权限
标签: android ios iphone ionic-framework http-post