qfetch
    Preparing search index...

    Type Alias MiddlewareExecutor

    MiddlewareExecutor: (next: FetchFn) => FetchFn

    A function that wraps a fetch function with middleware logic.

    Type Declaration

      • (next: FetchFn): FetchFn
      • Parameters

        • next: FetchFn

          The next fetch function in the middleware chain

        Returns FetchFn

        A new fetch function with the middleware applied

    Middleware executors form the building blocks of the middleware chain. Each executor receives the next function in the chain and returns a new fetch function with its logic applied. This pattern enables request/response interception, transformation, and error handling.

    // A simple logging middleware
    function withLogger(): MiddlewareExecutor {
    return (next) => async (input, init) => {
    console.log("Request:", input);
    const response = await next(input, init);
    console.log("Response:", response.status);
    return response;
    };
    }