I have an angular $resource
for login and getting user\'s info. The login sends the username and password to server and gets a Bearer token. In the succes
Your problem is that the resource definition is provided at the time of creation (before you have saved a token).
You can either add a general request interceptor to the $httpProvider
so all requests are covered or change your getEmail
action's header
to use a function so it is evaluated at run time, eg
headers: {
'Authorization': function() {
var token = $window.localStorage.getItem('TK');
return token ? 'Bearer ' + token : null;
}
}