Request and response interceptors, as the names suggest, can intercept HTTP requests and responses to augment/alter them. The typical use cases for using such interceptors include authentication, global error handling, manipulating HTTP headers, altering endpoint URLs, global retry logic, and some other such scenarios.
Interceptors are implemented as pipeline functions that get called one after another just like the parser and formatter pipelines for NgModelController
(see the previous chapter).
Interceptions can happen at four places and hence there are four interceptor pipelines. This happens:
Before a request is sent.
After there is a request error. A request error may sound strange but, in a pipeline mode when the request travels through the pipeline function and any one of them rejects the request (for reasons such as data validation), the request lands up on an error pipeline with the rejection reason.
After receiving the response from the server.
On receiving...