Response class represents the HTTP response received from a server. It provides methods to access various properties of the response.

Constructors

Properties

Accessors

Methods

Constructors

  • Constructor for the Response class. Initializes the properties of the class with the values from the provided response object.

    Parameters

    • response: TlsResponse

      The response object from which to initialize the class properties.

    Returns Response

Properties

headers: IncomingHttpHeaders
ok: boolean
response: TlsResponse

The response object from which to initialize the class properties.

status: number
url: string

Accessors

  • get cookies(): Record<string, string>
  • Returns the cookies from the response as an object with key-value pairs.

    Returns Record<string, string>

    An object containing cookies as key-value pairs.

Methods

  • Returns the body of the response as a JSON object.

    Type Parameters

    • T

    Returns Promise<T>

    A promise that resolves with the body of the response as a JSON object.

    Typeparam

    T - The type of the JSON object.

  • Returns the body of the response as a string.

    Returns Promise<string>

    A promise that resolves with the body of the response as a string.