Skip to content
Eugene Lazutkin edited this page Nov 26, 2019 · 3 revisions

It is an alternative default transport for making HTTP calls using fetch() instead of XHR.

Don't forget to consult the cookbook to see working snippets solving simple real-world problems.

The main API

io.fetch.attach()

Replaces the current default transport with itself.

io.fetch.detach()

Replaces the current default transport with the previous value.

Defaults and options

Various global defaults, which can be overridden on a per-request basis. The defaults are selected to emulate XHR as close as possible.

io.fetch.defaultMode, options.fetchMode

Specifies the default mode. Default: 'cors'.

Property fetchMode of request options is used to specify it on a per-request basis.

io.fetch.defaultCache, options.fetchCache

Specifies the default cache mode. Default: 'default'.

Property fetchCache of request options is used to specify it on a per-request basis.

io.fetch.defaultRedirect, options.fetchRedirect

Specifies the default redirect mode. Default: 'follow'.

Property fetchRedirect of request options is used to specify it on a per-request basis.

io.fetch.defaultReferrer, options.fetchReferrer

Specifies the default referrer mode. Default: 'client'.

Property fetchReferrer of request options is used to specify it on a per-request basis.

io.fetch.defaultReferrerPolicy, options.fetchReferrerPolicy

Specifies the default referrer policy. Default: 'no-referrer-when-downgrade'.

Property fetchReferrerPolicy of request options is used to specify it on a per-request basis.

io.fetch.defaultCredentials, options.fetchCredentials

Specifies the default credentials mode. Default: 'same-origin'.

The property fetchCredentials of request options is used to specify it on a per-request basis.

Clone this wiki locally