Created
June 1, 2015 08:54
-
-
Save Rokt33r/80a5dacbf07896aa7c55 to your computer and use it in GitHub Desktop.
Angular Http Interceptor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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