我有一段代碼,發送一個HTTP雙request.I希望首先進行身份驗證請求,如果真的執行下一條語句(即剛剛返回$ http promise)。我怎樣才能做到這一點angularJS。截至目前它正在返回undefined。
dmdb._login_request = function(credentials, conf) {
var p = {
'_method': 'POST',
'data[User][username]': credentials.login,
'data[User][password]': credentials.password
};
conf.headers = {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
};
var userData = {
'username': 'mbah',
'password': '[email protected]',
'applicationid': '1'
};
$http.post('myapp.com/authenticate/', userData, con).success(function(data) {
if (data.success) {
return $http.post(this.url + 'users/login', $.param(p), conf);
}
return $q.when('failed');
})
};
請複製並粘貼您的代碼,而不是提供的圖像 – Houseman
@Houseman剛剛做到了。請任何建議或提示,將不勝感激。 – mass