对于jsonwebtoken的一些疑问
是一个用户注册的场景,当用户post提交用户名和密码之后服务端返回该用户的accessToken
$http({
method: 'POST',
url: '/signin',
data: $scope.signinAccount
}).then(function(response){
// dosomething
}, function(error){
console.log(error.data);
});
请问拿到accessToken以后是应该存在localstorage里吗?然后每次在用户提交请求的时候在header里添上accessToken?
5 回复
bower install a0-angular-storage --save
A Storage done right for AngularJS.
Key Features
- Uses
localStorage
orsessionStorage
by default but if it’s not available, it usesngCookies
. - Lets you save JS Objects
- If you save a
Number
, you get aNumber
, not a String - Uses a caching system so that if you already have a value, it won’t get it from the store again.