Request: headers property
The headers property is the request headers, a Headers object.
Value
A Headers.
- Readable, not writable.
- When no
Content-Typewas given at construction but a body was, a default one is added based on the kind of body; for the rules, seeinit.bodyoffetch().
Examples
js
const req = new Request('https://httpbin.org/post', { method: 'POST', body: 'hello' });
console.log(req.headers.get('content-type'));Result: Prints text/plain;charset=UTF-8.
Differences from the web
Same as on the web.