fetch-cookie
fetch-cookie copied to clipboard
headers array unsupported
Observation
https://fetch.spec.whatwg.org/#typedefdef-headersinit lists two options for the headers field (passing the Headers
object isn't actually in the spec).
In lib.dom.d.ts
the field has the following type ( link )
type HeadersInit = [string, string][] | Record<string, string> | Headers;
This array format is unsupported by the current code (only Headers
objects or the dictionary form are).
Impact
// this works as expected the first time only, when there's no cookies yet
await fetchCookie(url, { headers: [["x-my-header": "my-header-value"]] });
// this overwrites the headers with the cookie -- removing any headers passed here. ⚠️
await fetchCookie(url, { headers: [["x-my-header": "my-header-value"]] });