vapor-chamber API reference - v1.3.0
    Preparing search index...

    Type Alias HttpConfig

    vapor-chamber — HTTP client

    Adapted and improved from useFetch (2026-02-05A). TypeScript rewrite aligned with vapor-chamber conventions and CDCC thresholds.

    Improvements over the original:

    • Full TypeScript types (no any casts)
    • CDCC-compliant function sizes
    • AbortSignal.any with manual fallback for older environments
    • Jitter on exponential backoff (avoids thundering herd)
    • X-RateLimit-Reset header as Retry-After fallback
    • 419 CSRF refresh coalesces concurrent requests (no duplicate refreshes)
    • session-expired CustomEvent + configurable callback
    • TimeoutError distinct from AbortError (user abort vs timeout)
    type HttpConfig = {
        timeout?: number;
        retry?: number;
        signal?: AbortSignal;
        csrf?: boolean;
        csrfCookieUrl?: string;
        headers?: Record<string, string>;
        onSessionExpired?: (status: number) => void;
    }
    Index

    Properties

    timeout?: number

    Request timeout in ms. Default: 10_000

    retry?: number

    Max retry attempts on 5xx/429/408. Default: 0

    signal?: AbortSignal

    External abort signal (e.g. from component unmount)

    csrf?: boolean

    Read CSRF token from DOM and attach as header. Default: false

    csrfCookieUrl?: string

    URL to fetch when a CSRF-expiry response (HTTP 419) occurs, to obtain a fresh token. The default targets the Laravel Sanctum SPA convention because it's the most common backend issuing 419 — override for other frameworks, or set to '' to disable the auto-refresh entirely (the lib will then only re-read the token from the DOM on retry). Default: '/sanctum/csrf-cookie'.

    headers?: Record<string, string>

    Additional headers merged into every request

    onSessionExpired?: (status: number) => void

    Called when a 401 session-expired response is received