Libraries
    Preparing search index...

    Function composeMiddleware

    • Composes an array of middlewares into a single wrapper around a FetchLike function.

      Middlewares are applied in array order — the first middleware is the outermost wrapper (executes first on the way in, last on the way out).

      Parameters

      • middlewares: Middleware[]

        An array of middleware functions to compose.

      • fetch: FetchLike

        The inner fetch implementation to wrap.

      Returns FetchLike

      A FetchLike function that runs through the full middleware chain.

      const enhanced = composeMiddleware([retry(), timeout()], globalThis.fetch);
      const response = await enhanced('/api/data', { method: 'GET' });