如何連接兩個$ http(.post)請求,以便一個在另一個之後被調用? 這是我的功能,這似乎不工作。
$scope.signup = function() {
console.log("New user");
$http.post('/signup',{
email: this.email,
password: this.password
}).then(function success($http){
return $http.post('api/userData/init'); //error
}).then(function redirect($state){
return $state.go('profile');
});
}
有什麼錯誤?你需要在第二個帖子上有一個回調函數 - '.then(函數成功($ http){...' –