Request/response interceptors

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 ...

Get AngularJS by Example now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.