qfetch
    Preparing search index...

    Module @qfetch/middlewares - v0.1.0

    @qfetch/middlewares

    Collection of all qfetch middlewares - convenience package for importing all middlewares at once.

    This package re-exports all official qfetch middlewares with pinned versions, providing a single import point for all middleware functionality.

    Included middlewares:

    • @qfetch/middleware-authorization - Authorization header injection with 401 retry
    • @qfetch/middleware-base-url - Base URL resolution
    • @qfetch/middleware-query-params - Query parameter management
    • @qfetch/middleware-retry-after - Retry-After header handling
    • @qfetch/middleware-retry-status - Status code based retry
    npm install @qfetch/middlewares @qfetch/core
    
    import {
    withAuthorization,
    withBaseUrl,
    withQueryParams,
    withRetryAfter,
    withRetryStatus,
    } from "@qfetch/middlewares";
    import { compose } from "@qfetch/core";

    const qfetch = compose(
    withRetryStatus({ statuses: [500, 502, 503], strategy: () => /* ... */ }),
    withRetryAfter(),
    withQueryParams({ version: "v2" }),
    withBaseUrl("https://api.example.com")
    )(fetch);

    await qfetch("/users");

    For more control over versions or to reduce bundle size, you can install middlewares individually:

    npm install @qfetch/middleware-base-url @qfetch/middleware-retry-status
    

    All exports from individual middleware packages are re-exported:

    • withAuthorization(opts) - Adds authorization headers with 401 retry
    • AuthorizationOptions, AuthorizationToken, TokenProvider types
    • withBaseUrl(baseUrl) - Resolves relative URLs against a base URL
    • withQueryParam(name, value, opts?) - Adds a single query parameter
    • withQueryParams(params, opts?) - Adds multiple query parameters
    • ArrayFormat, QueryParamOptions, QueryParamsOptions, QueryValue types
    • withRetryAfter(opts?) - Handles Retry-After response headers
    • RetryAfterOptions type
    • withRetryStatus(opts) - Retries on specific HTTP status codes
    • RetryStatusOptions type

    This package pins exact versions of all middleware dependencies to ensure consistent behavior. When new middleware versions are released, this package will be updated with a corresponding version bump.

    Classes

    ResponseError

    Interfaces

    BackoffStrategy
    TokenProvider

    Type Aliases

    AuthorizationOptions
    AuthorizationToken
    HeaderEntries
    HeadersInput
    QueryParamEntries
    QueryParamsOptions
    QueryParamValue
    ResponseErrorMapper
    ResponseErrorOptions
    RetryAfterOptions
    RetryStatusOptions

    Functions

    withAuthorization
    withBaseUrl
    withHeader
    withHeaders
    withQueryParam
    withQueryParams
    withResponseError
    withRetryAfter
    withRetryStatus