Fetch API
Fetch API
The Fetch API provides an interface for fetching resources (including across the network). It will seem familiar to anyone who has used XMLHttpRequest, but the new API provides a more powerful and flexible feature set.
Differences from jQuery
The fetch specification differs from jQuery.ajax() in three main ways:
- The Promise returned from
fetch()won’t reject on HTTP error status even if the response is an HTTP404or500. Instead, it will resolve normally (withokstatus set tofalse), and it will only reject on network failure or if anything prevented the request from completing. fetch()won't receive cross-site cookies. You can’t establish a cross site session usingfetch().Set-Cookieheaders from other sites are silently ignored.fetch()won’t send cookies, unless you set thecredentialsinit option.- Since Aug 25, 2017: The spec changed the default credentials policy to
same-origin. Firefox changed since 61.0b13.)
- Since Aug 25, 2017: The spec changed the default credentials policy to
Note: Find out more about using the Fetch API features in Using Fetch, and study concepts in Fetch basic concepts.
Fetch Interfaces
WindowOrWorkerGlobalScope.fetch()- The
fetch()method used to fetch a resource. Headers- Represents response/request headers, allowing you to query them and take different actions depending on the results.
Request- Represents a resource request.
Response- Represents the response to a request.
Using Fetch

浙公网安备 33010602011771号