An interceptor is a middleware code where all the $http
requests go through.
The interceptor is a factory that are registered in $httpProvider
. There are two types of requests that go through the interceptor, request and response (with requestError
and responseError
respectively).
This piece of code is very useful for error handling, authentication or middleware in all the requests/responses.