【发布时间】:2018-11-24 12:28:56
【问题描述】:
我有这个服务调用 apiService,在那里我可以得到在服务器端生成的令牌。
angular.module('miniMynd')
.service('apiService', function ($http) {
return {
loginUser: function(user){
$http.post("http://localhost:3010/api/login", user).then(function(response){
console.log(response.data) * I get the token*
})
},
}
});
我的登录Ctrl
$scope.login = function(){
$apiService.loginUser($scope.credentials); * I pass the crendentials to my function on the client side and i receive a token in the service above*
}
我尝试将令牌放入我的 $localStorage 中,但我收到了一个注入错误,因为只有提供者可以在配置块中注入。
【问题讨论】:
标签: angularjs jwt token access-token express-jwt