Logos DX
    Preparing search index...

    Interface FetchResponse<T, H, P, RH>

    Enhanced response object that provides comprehensive information about a fetch request and its result.

    Replaces the previous pattern of returning just parsed data with a rich response object containing the data, metadata, and request context. Designed to be easily destructurable while providing full access to HTTP response details.

    // Destructure just the data (backward compatibility pattern)
    const { data: user } = await api.get<User>('/users/123');
    // Access full response details
    const response = await api.get<User[]>('/users');
    console.log('Status:', response.status);
    console.log('Headers:', response.headers.get('content-type'));
    console.log('Data:', response.data);
    console.log('Request config:', response.config);
    // Use with error handling
    const [response, err] = await attempt(() => api.get('/users'));
    if (err) {
    console.error('Request failed:', err);
    return;
    }

    if (response.status === 200) {
    console.log('Success:', response.data);
    }
    interface FetchResponse<
        T = any,
        H = FetchEngine.InstanceHeaders,
        P = FetchEngine.InstanceParams,
        RH = FetchEngine.InstanceResponseHeaders,
    > {
        config: FetchConfig<H, P>;
        data: T;
        headers: Partial<RH>;
        request: Request;
        status: number;
    }

    Type Parameters

    Index

    Properties

    config: FetchConfig<H, P>

    Configuration used for the request.

    The merged configuration object that was used to make this request, including instance-level settings and request-specific overrides. Useful for debugging and understanding how the request was configured.

    data: T

    Parsed response body data.

    The response content parsed according to the content-type header or the configured determineType function. For JSON responses, this will be the parsed JavaScript object. For text responses, this will be a string.

    headers: Partial<RH>

    HTTP response headers received from the server.

    A plain object containing the response headers with type-safe access to headers you've defined in the InstanceResponseHeaders interface. All header names are preserved as-is from the server response.

    // Define your response headers
    declare module '@logosdx/fetch' {
    namespace FetchEngine {
    interface InstanceResponseHeaders {
    'x-rate-limit': string;
    'x-request-id': string;
    }
    }
    }

    // Now TypeScript knows about your response headers
    const response = await api.get('/users');
    const rateLimit = response.headers['x-rate-limit'];
    const requestId = response.headers['x-request-id'];
    request: Request

    Original request object.

    The Request object that was sent to the server, containing the final URL, headers, method, and body after all modifications and merging of instance and request-specific options.

    status: number

    HTTP status code.

    The numeric HTTP status code (200, 404, 500, etc.) returned by the server. Useful for conditional logic based on response status without needing to catch errors.