Skip to content

Instantly share code, notes, and snippets.

@DaveDevTV
DaveDevTV / angularAuth.js
Created May 1, 2016 02:05
How to Intercept HTTP requests from angular to include an authorization token
app.factory('TokenInterceptor', function($q, $cookies, $location, $rootScope, $injector) {
return {
request: function(config) {
config.headers = config.headers || {};
if($cookies.get('token')) {
config.headers.authorization = $cookies.get('token');
}
return config;
}
}