0
私はAnugularJSとExpressJSを使用してログイン画面を作成しています。 Postmanプラグインでうまく動作する認証API URLを作成しました。 Angularで投稿リクエストをすると、予期しないステータスコードが返されます。投稿要求が間違ったステータスコードを返します
ビュー
<input ng-model="login.name" type="text" placeholder="Admin User">
<input ng-model="login.password" type="password" placeholder="Password">
<div ng-click="logIn(login.name, login.password)">Login</div>
管理コントローラ
$scope.logIn = function logIn(username, password){
if(username !== undefined && password !== undefined) {
userservice.logIn(username, password).success(function(data){
authenticationservice.isLogged = true;
$window.sessionStorage.token = data.token;
$location.path("/dashboard");
}).error(function(status, data){
console.log(status);
console.log(data);
});
}
};
UserServiceの
.factory('userservice',['$http','$location', function ($http,$location) {
return {
logIn: function(name, password){
return $http.post($location.protocol() + '://'+ $location.host() +':'+ $location.port() +'/api/authenticate',{name: name, password: password});
}
}
}]);
ザ問題ポストマンPOSTを使用
、{名 "ABC"、 "パスワード:" 123" }と
http://localhost:8080/api/authenticate
は、返すべき{成功:false、ステータス:401};
しかし管理コントローラ・リターン・ステータス200からuserservice.logIn(ユーザー名、パスワード)たびに。