2017-07-13 6 views
-3

を試してみてくださいここに私のコードは

ですそれは仮引数

で働いたが、私はそれがfailuer

SERVIを得ログインするたびにacthually POSTメソッド

で仕事をdoesnot ce.js

service.Login = function(email, password, callback) { 
     var parameter = JSON.stringify({ 
     email: email, 
     password: password 
     }); 


     $http({ 
     method :'POST', 
     url:'//ec2-54-69-219-242.us-west-2.compute.amazonaws.com:8000/v1/customer/login/', 
     headers :{'Content-Type': 'application/application/x-www-form-urlencoded'}, 
     data: parameter // pass in data as strings 
     // set the headers so angular passing info as form data (not request payload) 
     }) 
     .then(function(response) { 

      callback(response); 
     }, 
     function(response){ 


     alert(JSON.stringify(response)); 


    }); 


    }; 

そして私私はポストのすべての異なる種類を(変更しよう$ http.post上failuer応答()でも

{ 
    "data": "", 
    "status": 0, 
    "config": { 
    "method": "POST", 
    "transformRequest": [ 
     null 
    ], 
    "transformResponse": [ 
     null 
    ], 
    "url": "//ec2-54-69-219-242.........com:8000/v1/customer/login/", 
    "headers": { 
     "Content-Type": "application/application/x-www-form-urlencoded", 
     "Accept": "application/json, text/plain, */*", 
     "Authorization": "Basic " 
    }, 
    "data": "{\"email\":\"[email protected]\",\"password\":\"password\"}" 
    }, 
    "statusText": "" 
} 

を得た)

以下のようにアクセス
var parameter = JSON.stringify({ 
      email: email, 
      password: password 
      }); 
var res = $http.post('//ec2-54-69-219-242.us-west-2.compute.amazonaws.com:8000/v1/customer/login/',parameter); 
     res.success(function(data, status, headers, config) { 
      callback(data); 
     }); 
     res.error(function(data, status, headers, config) { 
      alert("failure message: " + JSON.stringify({data: data})); 
     }); 

私はこれを手伝ってくれます。

Serverは、あなたのJSONをstringfyシンプルなJSONを送信し、コンテンツタイプを設定しないでくださいリクエストとレスポンス

Method: POST 
Request: 
{ 
"email":"[email protected]", 
"password":"test" 
} 
Response: 
{ 
    "meta": "", 
    "data": 
     { 
      "username": "sandeep", 
      "bio": "studying", 
      "pic": "url", 
      "email": "[email protected]" 
     } 
} 

答えて

0

として以下のようなJSONオブジェクト内のデータが欲しい:アプリケーション/ JSON

+0

{ "データ": ""、 "ステータス":0、 "設定":{ "方法": "POST"、 "transformRequest":[ ヌル ]、 "transformResponse":[ ヌル ]、 "URL": " //ec2-54-69-219-242.us-west-2.compute.amazon 「アプリケーション/ json、text/plain、*/*」: 「コンテンツタイプ」:「アプリケーション/ json」、 「受け入れる」: " "認可": "基本" }、 "データ":{ "電子メール": "[email protected]"、 "パスワード": "パスワード" }} 、 " STATUSTEXT ":" " } –

+0

まだ動作していません –

+0

@SandeepGadhiyaあなたのデータは正しい形式です。あなたが望むように。私にはサーバー側の問題が好きです。サーバー側からデバッグして確認できますか? –

関連する問題