Web globals
new Headers()
Constructs a normalized HTTP header collection. Do not copy all inbound headers to an outbound request without an allowlist. Tested on Node.js 22.16.0. Example output (one line per entry): ["lab-7 false"].
Formal Syntax & Structure
nodejs syntaxnodejs
new Headers([init])Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| init | object | Array | Initial headers. |
Return Value
Headers
Header collection.
Working Example
Example Snippetnodejs
const h = new Headers({ 'X-Request-ID': 'lab-7' });console.log(h.get('x-request-id'), h.has('authorization'));