拦截器中的AngularJS头授权格式
我是个新手。我正在实现基于令牌的授权。后端开发人员希望我通过标头发送令牌 以这种格式{auth_token:whatever}。我的问题是我的标题配置是否遵循正确的fomat拦截器中的AngularJS头授权格式,angularjs,http-headers,authorization,interceptor,Angularjs,Http Headers,Authorization,Interceptor,我是个新手。我正在实现基于令牌的授权。后端开发人员希望我通过标头发送令牌 以这种格式{auth_token:whatever}。我的问题是我的标题配置是否遵循正确的fomat angular.module('sampleModule').factory('httpRequestInterceptor', ['$localStorage', function($localStorage) //I'm using the ng-storage library { retur
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;
}
};
}]);