Returns {
(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
(input: string | Request | URL, init?: RequestInit): Promise<Response>;
}
A drop-in replacement for the standard fetch function routing every exchange through middlewares
-
- (input: RequestInfo | URL, init?: RequestInit): Promise<Response>
-
Parameters
- input: RequestInfo | URL
Optionalinit: RequestInit
Returns Promise<Response>
- (input: string | Request | URL, init?: RequestInit): Promise<Response>
-
Parameters
- input: string | Request | URL
Optionalinit: RequestInit
Returns Promise<Response>
Creates a fetch client from a chain of middlewares.
Layers
middlewaresover the standardfetchfunction in declaration order: requests are processed by the first middleware first and reach the standard function last; responses travel back through the chain in reverse. An empty chain yields the standard function itself.The standard function is resolved when the chain is assembled, so a client routes through a global replaced before its creation, such as a test double or a polyfill installed at start-up, but not through one replaced afterwards. To bind a client to an implementation of its own, regardless of the global one, close the chain with transport.