kinetex - v1.0.0-rc.1
    Preparing search index...

    Interface SendOptions<T>

    Options passed to individual request methods — override instance defaults.

    interface SendOptions<T = unknown> {
        baseURL?: string;
        headers?: HeadersInit;
        params?: QueryParams;
        body?: BodyInit;
        timeout?: number;
        retry?: false | Partial<RetryConfig>;
        auth?: false | AuthConfig;
        proxy?: false | ProxyConfig;
        maxRequestSize?: number;
        signal?: AbortSignal;
        cache?: false | CacheRequestConfig;
        maxResponseSize?: number;
        throwOnError?: boolean;
        followRedirects?: boolean;
        maxRedirects?: number;
        httpVersion?: HTTPVersion;
        onUploadProgress?: ProgressCallback;
        onDownloadProgress?: ProgressCallback;
        tags?: string[];
        parseResponse?: (
            raw: Uint8Array,
            headers: Record<string, string>,
            url: string,
        ) => T | Promise<T>;
        parseFailure?: (raw: Uint8Array, error: Error) => void;
        onSuccess?: (res: KinetexResponse<T>) => void;
        onError?: (err: KinetexError) => void;
        meta?: Record<string, unknown>;
    }

    Type Parameters

    • T = unknown

      Expected parsed response body type.

    Index

    Properties

    baseURL?: string

    Override base URL for this request.

    headers?: HeadersInit

    Additional / override headers.

    params?: QueryParams

    Query parameters (merged with instance defaults).

    body?: BodyInit

    Request body.

    timeout?: number

    Override timeout in ms.

    retry?: false | Partial<RetryConfig>

    Override retry config.

    auth?: false | AuthConfig

    Override auth.

    proxy?: false | ProxyConfig

    Override proxy.

    maxRequestSize?: number

    Maximum request body size in bytes. 0 = no limit.

    signal?: AbortSignal

    AbortSignal.

    cache?: false | CacheRequestConfig

    Per-request cache config.

    maxResponseSize?: number

    Response size limit in bytes.

    throwOnError?: boolean

    Whether to throw on HTTP 4xx/5xx.

    followRedirects?: boolean

    Whether to follow redirects.

    maxRedirects?: number

    Max redirects.

    httpVersion?: HTTPVersion

    Preferred HTTP version.

    onUploadProgress?: ProgressCallback

    Upload progress callback.

    onDownloadProgress?: ProgressCallback

    Download progress callback.

    tags?: string[]

    Cache tags for invalidation.

    parseResponse?: (
        raw: Uint8Array,
        headers: Record<string, string>,
        url: string,
    ) => T | Promise<T>

    Response body parser. Defaults to JSON for application/json, text otherwise.

    parseFailure?: (raw: Uint8Array, error: Error) => void

    Called when the default body parser silently falls back from JSON to raw text due to a parse error.

    This makes implicit type-conversion failures visible without requiring a custom parseResponse. Useful for monitoring and debugging content-type mismatches in production.

    Type Declaration

      • (raw: Uint8Array, error: Error): void
      • Parameters

        • raw: Uint8Array

          The raw response body bytes.

        • error: Error

          The parse error that caused the fallback.

        Returns void

    const res = await client.get<User>("/profile", {
    parseFailure: (raw, err) => {
    logger.warn("JSON parse failed, got text instead", { error: err.message });
    },
    });
    onSuccess?: (res: KinetexResponse<T>) => void

    Callback invoked on successful response.

    Alternative to the promise return pattern. If both onSuccess and the promise are used, the callback is invoked first, then the promise resolves.

    client.get("/data", {
    onSuccess: (res) => console.log("Got:", res.data),
    onError: (err) => console.error("Failed:", err.message),
    });
    onError?: (err: KinetexError) => void

    Callback invoked on request/response error.

    Called for both network errors and HTTP error responses (4xx/5xx when throwOnError is true). Use this for callback-style error handling without try/catch.

    meta?: Record<string, unknown>

    Arbitrary metadata attached to the request.