【发布时间】:2017-07-14 09:01:46
【问题描述】:
我有一段代码发送一个双重 HTTP 请求。我想首先发出一个身份验证请求,如果为真,则执行下一条语句(它只返回一个 $http 承诺)。我怎样才能在 angularJS 中做到这一点。截至目前,它正在返回未定义。
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': 'abc@123',
'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 刚刚做到了。请任何建议或提示将不胜感激。
标签: javascript jquery angularjs reactjs https