Fetch API
chevron down
 

Fetch API

fetch()

This API is used to GET and POST across a network.

Please note: fetch() can only be used to access https endpoints and resources, except when accessing resources on a local network by IP address.

Fetch API

fetch.fetch(input: RequestInfo, init?: RequestInit | undefined)

Parameters

input: RequestInfo
(optional) init: RequestInit or undefined

ResponseType

String: "error" | "default"

Interface: ResponseInit

Properties

headers

Headers or string[][] or { [key: string]: string; } or undefined

status

number or undefined

statusText

string or undefined

Class: Response

Properties

readonly bodyUsed

boolean

readonly headers

Headers

readonly ok

boolean

readonly status

number

readonly statusText

string

readonly type

ResponseType

readonly url

string

Methods

arrayBuffer()

Returns: Promise<ArrayBuffer>

blob()

Returns: Promise<Blob>

clone()

Returns: Response

formData()

Returns: Promise<FormData>

json()

Returns: Promise<any>

text()

Returns: Promise<string>

RequestCredentials

String: "omit" | "same-origin" | "include"

Interface: RequestInit

Properties

body

string or ArrayBuffer or ArrayBufferView or Blob or FormData or undefined

credentials

"omit" or "same-origin" or "include" or undefined

headers

Headers or string[][] or { [key: string]: string; } or undefined

method

string or undefined

Class: Request

Properties

readonly bodyUsed

boolean

readonly credentials

RequestCredentials

readonly headers

Headers

readonly method

string

readonly url

string

Methods

arrayBuffer()

Returns: Promise<ArrayBuffer>

blob()

Returns: Promise<Blob>

clone()

Returns: Request

formData()

Returns: Promise<FormData>

json()

Returns: Promise<any>

text()

Returns: Promise<string>

RequestInfo

String: string | Request

Interface: Body

Properties

readonly bodyUsed

boolean

Methods

arrayBuffer()

Returns: Promise<ArrayBuffer>

blob()

Returns: Promise<Blob>

formData()

Returns: Promise<FormData>

json()

Returns: Promise<any>

text()

Returns: Promise<string>

ResponseBodyInit

String: string | ArrayBuffer | ArrayBufferView | Blob | FormData

BodyInit

String: string | ArrayBuffer | ArrayBufferView | Blob | FormData

Class: Headers

Methods

append()

append(name: string, value: string)

Returns: void

delete()

delete(name: string)

Returns: void

entries()

Returns: IterableIterator<string, string>

forEach()

forEach(callback: (value: string, key: string, headers: Headers) => void, thisArg?: any)

Returns: void

get()

get(name: string)

Returns: string or null

has()

has(name: string)

Returns: boolean

keys()

Returns: IterableIterator<string>

set()

set(name: string, value: string)

Returns: void

values()

Returns: IterableIterator<string>

HeadersInit

String: Headers | string[][] | { [key: string]: string; }