1
我使用deployd模擬http請求。我想用我的憑據對數據庫進行身份驗證。http呼叫總是成功,無論憑據
這是我的控制器代碼
.controller("authCtrl", function($scope, $http, $location, authUrl) {
$scope.authenticate = function (user, pass) {
$http.post(authUrl, {
username: user,
password: pass
}).success(function (data) {
console.log(data);
$location.path("main");
}).error(function (error) {
console.log("error");
$scope.authenticationError = error;
});
}
})
我得到輸入憑據錯誤之一後,下面的消息。
Object { message: "bad credentials", status: 401 }
我在正確輸入兩個憑據後得到以下消息。
Object { path: "/users", id: "11a58ccdcc31c9b863b7a5e63d9d672fdae…", uid: "e2ad770f0847f8ac" }
我的問題是沒有得到「錯誤」日誌。只有成功事件被解僱。輸入憑據錯誤或權利不會改變這種情況。
您運行的是什麼版本的角度? – cbass
你有沒有改變'responseError'處理程序像[這裏](http://stackoverflow.com/questions/15888162/angularjs-http-error-function-never-called)? –
我正在使用AngularJS v1.2.0。 –