fetch-cookie icon indicating copy to clipboard operation
fetch-cookie copied to clipboard

headers array unsupported

Open sparecycles opened this issue 1 year ago • 0 comments

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;

image

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"]] });

sparecycles avatar Sep 22 '23 04:09 sparecycles