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

blob()

Returns: Promise

clone()

Returns: Response

formData()

Returns: Promise

json()

Returns: Promise

text()

Returns: Promise

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

blob()

Returns: Promise

clone()

Returns: Request

formData()

Returns: Promise

json()

Returns: Promise

text()

Returns: Promise

RequestInfo

String: string | Request

Interface: Body

Properties

readonly bodyUsed

boolean

Methods

arrayBuffer()

Returns: Promise

blob()

Returns: Promise

formData()

Returns: Promise

json()

Returns: Promise

text()

Returns: Promise

ResponseBodyInit

String: string | ArrayBuffer | ArrayBufferView | Blob | FormData

BodyInit

String: string | ArrayBuffer | ArrayBufferView | Blob | FormData

Interface: FormData

Methods

append()

append(name: string, value: string | Blob, fileName?: string | undefined)

Returns: void

delete()

delete(name: string)

Returns: void

get()

get(name: string)

Returns: string or null

getAll()

getAll(name: string)

Returns: string[]

has()

has(name: string)

Returns: boolean

set()

set(name: string, value: string | Blob, fileName?: string | undefined)

Returns: void

FormDataEntryValue

String: string

Class: Headers

Methods

append()

append(name: string, value: string)

Returns: void

delete()

delete(name: string)

Returns: void

entries()

Returns: Iterator<string, string>

forEach()

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

Returns: void

get()

get(name: string)

Returns: string or null

has()

has(name: string)

Returns: boolean

keys()

Returns: Iterator

set()

set(name: string, value: string)

Returns: void

values()

Returns: Iterator

HeadersInit

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

Fetch API