Hierarchy

  • FetchResponse

Properties

Readonly body

body: ReadableStream | null

Response as a stream.

Readonly bodyUsed

bodyUsed: boolean

Whether body was used.

Readonly headers

headers: Readonly<ReadonlyMap<string, string>>

Response headers.

const result = await fetch('https://yandex.ru');
// Getting a list of  response headers as JSON files 
const headersJson = JSON.stringify(Object. fromEntries(result.headers)); 
// Getting the value of a response header  
const setCookie = result.headers.get('set-cookie'); 

Readonly ok

ok: boolean

Short flag indicating that the response code is less than 300.

Readonly size

size: number

Response size in bytes.

Readonly status

status: HttpStatusCode | number

HTTP response code.

For more information about codes, see HttpStatusCode.

Readonly statusText

statusText: string

Text view of the response code.

Readonly timeout

timeout: number

Request execution timeout in milliseconds.

Readonly type

type: "basic" | "cors" | "default" | "error" | "opaque" | "opaqueredirect"

Type of the response.

Readonly url

url: string

Address of the resource.

Methods

arrayBuffer

  • arrayBuffer(): Promise<ArrayBuffer>
  • Wait for the complete response and return is as an array of binary data.

    Returns Promise<ArrayBuffer>

blob

  • blob(): Promise<Blob>
  • Wait for the complete response and return in as a Blob.

    Returns Promise<Blob>

json

  • json(): Promise<any>
  • Wait for the complete response and parse it as JSON.

    Returns Promise<any>

text

  • text(): Promise<string>
  • Wait for the complete response and return it as text.

    Returns Promise<string>