Hierarchy

  • FetchResponse

Properties

headers

headers: 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'); 

ok

ok: boolean

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

size

size: number

Response size in bytes.

status

status: HttpStatusCode | number

HTTP response code.

For more information about codes, see HttpStatusCode.

statusText

statusText: string

Text view of the response code.

timeout

timeout: number

Request execution timeout in milliseconds.

type

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

Type of the response.

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>

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>