Skip to content

Instantly share code, notes, and snippets.

@Rokt33r
Created June 1, 2015 08:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rokt33r/80a5dacbf07896aa7c55 to your computer and use it in GitHub Desktop.
Save Rokt33r/80a5dacbf07896aa7c55 to your computer and use it in GitHub Desktop.
Angular Http Interceptor
angular.module('some-module')
.factory('myHttpInterceptor', ['$q', '$location', function($q, $location) {
return {
response: function(response) {
return response;
},
responseError: function(response) {
if (response.status === 401) {
$location.path('/admin/login');
return $q.reject(response);
}
return $q.reject(response);
}
};
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment