AngularJS header authorization format in Interceptor

97 views Asked by At

I am very new to angular. I am implementing a token based authorization. The backend developer wants me to send the token through the header in this format {auth_token: whatever}. My question is if my header config is following the correct fomat.

angular.module('sampleModule').factory('httpRequestInterceptor',
     ['$localStorage', function($localStorage) //I'm using the ng-storage library
    {
    return {
    request: function($config) {
     if( $localStorage.accessToken )
     {
      $config.headers['auth_token'] = $localStorage.accessToken; //is this following my backend developer's format {auth_token: whatever}? 
     }


 return $config;
}
};
}]);
0

There are 0 answers