Created
June 10, 2016 09:16
-
-
Save JulienSansot/8bba78154ab5306516b72a9057c71b66 to your computer and use it in GitHub Desktop.
intercept error in angular
This file contains hidden or 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
(function(){ | |
var httpInterceptor = function ($provide, $httpProvider) { | |
$provide.factory('httpInterceptor', function ($q) { | |
return { | |
response: function (response) { | |
return response || $q.when(response); | |
}, | |
responseError: function (rejection) { | |
if(rejection.status === 401) { | |
// you are not autorized | |
} | |
return $q.reject(rejection); | |
} | |
}; | |
}); | |
$httpProvider.interceptors.push('httpInterceptor'); | |
}; | |
angular.module("dashboard").config(httpInterceptor); | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment