Skip to content

Instantly share code, notes, and snippets.

@sylouuu
Created June 2, 2015 14:00
Show Gist options
  • Save sylouuu/29956ec51d4187e7485c to your computer and use it in GitHub Desktop.
Save sylouuu/29956ec51d4187e7485c to your computer and use it in GitHub Desktop.
AngularJS Custom HTTP Interceptor
app.config(function ($httpProvider) {
$httpProvider.interceptors.push('customHttpInterceptor');
});
app.factory('customHttpInterceptor', function ($q) {
return {
// HTTP request success
request: function (config) {
return config;
},
// HTTP request error
requestError: function (response) {
return $q.reject(response);
},
// HTTP response success
response: function (response) {
return response;
},
// HTTP response error
responseError: function (response) {
return $q.reject(response);
}
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment