Tin mới
JavaScript: Scripting language
Web APIs: Programming interfaces
Structuring content with HTML module
Dynamic scripting with JavaScript module
Cross-Origin Resource Sharing (CORS)
The Fetch API provides a JavaScript interface for making HTTP requests and processing the responses.
By default, fetch() makes a GET request, but you can use the method option to use a different request method:
By default, fetch() makes a GET request, but you can use the method option to use a different request method:
Request headers give the server information about the request: for example, in a POST request, the Content-Type header tells the server the format of the request's body.
GET requests don't have a body, but you can still send data to the server by appending it to the URL as a query string. This is a common way to send form data to the server. You can do this by using URLSearchParams to en
Whether a request can be made cross-origin or not is determined by the value of the RequestInit.mode option. This may take one of three values: cors, same-origin, or no-cors.
In the context of the Fetch API, a credential is an extra piece of data sent along with the request that the server may use to authenticate the user. All the following items are considered to be credentials:
In the context of the Fetch API, a credential is an extra piece of data sent along with the request that the server may use to authenticate the user. All the following items are considered to be credentials:
Access-Control-Allow-Credentials
In the context of the Fetch API, a credential is an extra piece of data sent along with the request that the server may use to authenticate the user. All the following items are considered to be credentials:
The Request() constructor takes the same arguments as fetch() itself. This means that instead of passing options into fetch(), you can pass the same options to the Request() constructor, and then pass that object to fetc
To make a request cancelable, create an AbortController, and assign its AbortSignal to the request's signal property.
To make a request cancelable, create an AbortController, and assign its AbortSignal to the request's signal property.
To make a request cancelable, create an AbortController, and assign its AbortSignal to the request's signal property.
As soon as the browser has received the response status and headers from the server (and potentially before the response body itself has been received), the promise returned by fetch() is fulfilled with a Response object
The promise returned by fetch() will reject on some errors, such as a network error or a bad scheme. However, if the server responds with an error like 404, then fetch() fulfills with a Response, so we have to check the