Skip to content

Type Alias: Interceptor()

@kortexya/reasoninglayer


@kortexya/reasoninglayer / Interceptor

Type Alias: Interceptor()

Interceptor = (request, next) => Promise<Response>

Defined in: src/types/common.ts:74

Interceptor function for the HTTP request pipeline.

Interceptors are called in order. Each interceptor receives the request and a next function to pass the request to the next interceptor (or the actual fetch call).

Parameters

request

Request

next

(req) => Promise<Response>

Returns

Promise<Response>

Example

const loggingInterceptor: Interceptor = async (request, next) => {
console.log(`${request.method} ${request.url}`);
const response = await next(request);
console.log(`${response.status}`);
return response;
};