Im making an AngularJS Application and Im trying to insert JSONwebtoken into the headers, but I can't figure out what's wrong with my code. Can you guys help me out?
My application config:
application.config(['$routeProvider','$httpProvider', '$locationProvider', function($routeProvider, $locationProvider, $localStorage, $window, $httpProvider) {
$httpProvider.interceptors.push('AuthInterceptors');
}]);
And my AuthInterceptors factory:
application.factory("AuthInterceptors", function(AuthToken) {
var authInterceptorsFactory = {};
authInterceptorsFactory.request = function(config) {
var token = AuthToken.getToken();
if(token) config.headers['x-access-token'] = token;
return config;
};
return authInterceptorsFactory;
});
Thanks guys!