簡體   English   中英

來自應用的HTTP POST請求在iPhone上有效,但在Android手機上無效

[英]HTTP POST request from app works on iPhone but not on Android phone

在我的離子應用程序中,我有一個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手機上工作。

可能與URL前綴有關。 您是否嘗試過使用:

apiDomain = @"https://cues-server-dev.elasticbeanstalk.com"

要么

apiDomain = @"http://www.cues-server-dev.elasticbeanstalk.com"

或其他一些變體。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM