Options
All
  • Public
  • Public/Protected
  • All
Menu

Represents an HTTP response.

Hierarchy

  • Response

Index

Constructors

constructor

  • Constructs a new HTTP response.

    Parameters

    • Optional body: null | HttpBody

      The HTTP response body.

    • Optional init: ResponseInit

      Response initialization metadata.

    Returns Response

Accessors

body

  • Gets the body of the response as ReadableStream.

    This can only be called once. Subsequent accesses will throw a TypeError.

    Returns null | ReadableStream<any>

bodyUsed

  • get bodyUsed(): boolean
  • Returns whether the body has already been used and subsequent accesses would throw.

    Returns boolean

headers

  • Gets the HTTP response headers.

    Returns Headers

ok

  • get ok(): boolean
  • Returns whether the response's status code indicates success.

    Success is defined as HTTP status codes 200-299 (inclusive).

    Returns boolean

redirected

  • get redirected(): boolean
  • Returns whether the response was redirected.

    Returns boolean

status

  • get status(): number
  • Returns the HTTP status code.

    Returns number

statusText

  • get statusText(): string
  • Returns the status message corresponding to the status code.

    Returns string

url

  • get url(): string
  • Gets the URL that was ultimately fetched (after redirects).

    Returns string

Methods

arrayBuffer

  • arrayBuffer(): Promise<ArrayBuffer>
  • Returns a promise that resolves with the response data read into an ArrayBuffer.

    Be aware, this reads the entire response into memory, and thus may easily exceed your heap limit.

    Returns Promise<ArrayBuffer>

json

  • json(): Promise<any>
  • Attempts to deserialize the response body as JSON.

    Returns Promise<any>

text

  • text(): Promise<string>
  • Reads the response body to a string. The text is decoded using UTF-8.

    Returns Promise<string>

Generated using TypeDoc