The Request object represents a resource request, and it’s usually created using the new Request() API.
Example:
const req = new Request('/api/todos')
The Request object offers several read-only properties to inspect the resource request details, including
method: the request’s method (GET, POST, etc.)url: the URL of the request.headers: the associated Headers object of the requestreferrer: the referrer of the requestcache: the cache mode of the request (e.g., default, reload, no-cache).
And exposes several methods including json(), text() and formData() to process the body of the request.
The full API can be found at https://developer.mozilla.org/docs/Web/API/Request
Lessons in this unit:
| 0: | Introduction |
| 1: | How to use Fetch |
| 2: | Catching errors in network requests |
| 3: | The Response object |
| 4: | Getting the body content |
| 5: | ▶︎ The Request object |
| 6: | Request headers |
| 7: | POST requests |