Interceptor

noun

say it: “in-ter-SEP-ter” /ˌɪntərˈsɛptər/

A function that sees every HTTP request and response in one place, such as to add a token.

What is Interceptor?

An interceptor is a function that sees every HTTP request and response, so you can add headers, show a loading spinner or handle errors in one place.

export const loggingInterceptor: HttpInterceptorFn = (req, next) => {
  console.log('Calling', req.url);
  return next(req);
};

provideHttpClient(withInterceptors([loggingInterceptor]))

In a sentence

  • “Our interceptor adds the Authorization header to every API call.”

Level: Journeyman · More Angular terms at this level

Updated