W3cubDocs

/Angular

HttpInterceptorFn

type-alias

An interceptor for HTTP requests made via HttpClient.

See more...

type HttpInterceptorFn = (req: HttpRequest<unknown>, next: HttpHandlerFn) => Observable<HttpEvent<unknown>>;

Description

HttpInterceptorFns are middleware functions which HttpClient calls when a request is made. These functions have the opportunity to modify the outgoing request or any response that comes back, as well as block, redirect, or otherwise change the request or response semantics.

An HttpHandlerFn representing the next interceptor (or the backend which will make a real HTTP request) is provided. Most interceptors will delegate to this function, but that is not required (see HttpHandlerFn for more details).

HttpInterceptorFns have access to inject() via the EnvironmentInjector from which they were configured.

© 2010–2023 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://angular.io/api/common/http/HttpInterceptorFn