Member Junction
    Preparing search index...

    The result of a request. Returned for 2xx responses, and — when ThrowOnError is disabled — for any response at all.

    The axios equivalent is its response object, with the fields renamed to MJ's PascalCase convention: data -> Data, status -> Status, headers -> Headers.

    interface Repo { id: number; full_name: string }
    const response = await HttpGet<Repo>('https://api.github.com/repos/a/b');
    response.Data.full_name; // typed as string
    response.Status; // 200
    response.Headers['etag']; // header keys are always lower-cased
    interface HttpResponse<T = unknown> {
        Data: T;
        Headers: Record<string, string>;
        Ok: boolean;
        Status: number;
        StatusText: string;
        Url: string;
    }

    Type Parameters

    • T = unknown

      the shape of the parsed response body. Supply it at the call site (HttpGet<Payload>(...)) so Data is typed rather than unknown.

    Index

    Properties

    Data: T

    The parsed response body, per the request's ResponseType.

    Headers: Record<string, string>

    Response headers, lower-cased keys.

    Ok: boolean

    True when Status is in the 2xx range.

    Status: number

    HTTP status code.

    StatusText: string

    HTTP status text.

    Url: string

    The final URL the response came from (after any redirects).