Middleware function for intercepting and modifying HTTP requests/responses.
Middlewares form a chain where each can modify the request before passing to the next, and modify the response after receiving it.
The outgoing Request object
Function to pass control to the next middleware
A Promise resolving to the Response
const authMiddleware: FetchMiddleware = async (request, next) => { request.headers.set('Authorization', `Bearer ${token}`); const response = await next(request); // Optionally transform response return response;}; Copy
const authMiddleware: FetchMiddleware = async (request, next) => { request.headers.set('Authorization', `Bearer ${token}`); const response = await next(request); // Optionally transform response return response;};
Middleware function for intercepting and modifying HTTP requests/responses.
Middlewares form a chain where each can modify the request before passing to the next, and modify the response after receiving it.