Skip to content

Commit

Permalink
docs: garbage collection HEAD method note (#1522)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrkldshv committed Jul 2, 2022
1 parent e53242d commit 57e2434
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README.md
Expand Up @@ -283,6 +283,13 @@ const headers = await fetch(url)
.then(res => res.headers)
```

However, if you want to get only headers, it might be better to use `HEAD` request method. Usage of this method will obviate the need for consumption or cancelling of the response body. See [MDN - HTTP - HTTP request methods - HEAD](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/HEAD) for more details.

```js
const headers = await fetch(url, { method: 'HEAD' })
.then(res => res.headers)
```

##### Forbidden and Safelisted Header Names

* https://fetch.spec.whatwg.org/#cors-safelisted-response-header-name
Expand Down

0 comments on commit 57e2434

Please sign in to comment.