The Fetch API provides an interface for fetching resources (including across the network). It will seem familiar to anyone who has used
XMLHttpRequest, but it provides a more powerful and flexible feature set. This article explains some of the basic concepts of the Fetch API.
Note: This article will be added to over time. If you find a Fetch concept that you feel needs explaining better, let someone know on the MDN Web Docs chat rooms.
At the heart of Fetch are the Interface abstractions of HTTP
Headers, along with a
Service Workers is an example of an API that makes heavy use of Fetch.
Fetch takes the asynchronous nature of such requests one step further. The API is completely
Guard is a feature of
Headers objects, with possible values of
none, depending on where the header is used.
When a new
Headers object is created using the
Headers() constructor, its guard is set to
none (the default). When a
Response object is created, it has an associated
Headers object whose guard is set as summarized below:
|new object's type
|guard setting of associated
A header's guard affects the
append() methods which change the header's contents. A
TypeError is thrown if you try to modify a
Headers object whose guard is
immutable. However, the operation will work if