Fetch Client API Documentation - v1.1.1
    Preparing search index...

    Class ApiResponse

    Represents an enhanced HTTP response with intelligent parsing capabilities. This class wraps the native Fetch API Response and automatically determines the appropriate parsing strategy for the returned data.

    Index

    Constructors

    • Constructs an instance of ApiResponse.

      Parameters

      • response: Response

        The native Fetch API Response object.

      • request: ApiRequest

        The associated ApiRequest that generated this response.

      Returns ApiResponse

    Properties

    response: Response

    The native Fetch API Response object.

    request: ApiRequest

    The associated ApiRequest that generated this response.

    Accessors

    • get ok(): boolean

      Indicates whether the HTTP response status is within the successful range (200–299).

      Returns boolean

      true if the response is successful, otherwise false.

    • get status(): number

      Returns the numeric HTTP status code of the response.

      Returns number

      200, 404, 500, etc.
      
    • get statusText(): string

      Returns the HTTP status text of the response.

      Returns string

      "OK", "Not Found", "Internal Server Error"
      
    • get headers(): Headers

      Returns all response headers as a Headers object.

      Returns Headers

    Methods

    • Retrieves and parses the response body automatically based on the request configuration.

      Type Parameters

      • T = unknown

        The expected type of the parsed data.

      Returns Promise<T>

      A promise resolving to the parsed data of type T.

      Supported response types:

      • json
      • text
      • blob
      • arrayBuffer
      • auto (default – automatically detects format)
    • Parses the response as JSON.

      Type Parameters

      • T = unknown

        The expected JSON object type.

      Returns Promise<T>

      A promise resolving to parsed JSON data.

      If the response body cannot be parsed as JSON.

    • Parses the response as plain text.

      Returns Promise<string>

      A promise resolving to a string value.

      If the text body cannot be retrieved.

    • Parses the response as a binary Blob.

      Returns Promise<Blob>

      A promise resolving to a Blob object.

      If the blob body cannot be retrieved.

    • Parses the response as an ArrayBuffer.

      Returns Promise<ArrayBuffer>

      A promise resolving to an ArrayBuffer.

      If the array buffer cannot be retrieved.