1

I am working with a node js rest api. In the authentication process api returns an access token. I need to add the access token to every request from an common place.

Dushantha
  • 103
  • 3
  • 9

1 Answers1

3

You can use http interceptor
Code looks like as follow

$httpProvider.interceptors.push(function($q, $cookies) {
  return {
   'request': function(config) {
        config.headers['Token'] = $cookies.loginTokenCookie;
        return config;
    }
  };
});

From this post

Community
  • 1
  • 1
Divyesh Savaliya
  • 2,692
  • 2
  • 18
  • 37