diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e41e8aef..155ea01f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,8 +12,8 @@ jobs: strategy: matrix: - node-version: [18.x] - # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + node-version: [18.x, 20.x] + # See supported Node.js release schedule at https://nodejs.org/en/about/previous-releases steps: - uses: actions/checkout@v3 diff --git a/README.md b/README.md index 0afa9c5a..4d6e7280 100644 --- a/README.md +++ b/README.md @@ -132,8 +132,8 @@ such as injecting headers or adding log statements. ```js replicate.fetch = (url, options) => { - const headers = new Headers(options && options.headers); - headers.append("X-Custom-Header", "some value"); + const headers = options && options.headers ? { ...options.headers } : {}; + headers["X-Custom-Header"] = "some value"; console.log("fetch", { url, ...options, headers }); diff --git a/biome.json b/biome.json index 63919df3..807b9013 100644 --- a/biome.json +++ b/biome.json @@ -17,15 +17,16 @@ "useMediaCaption": "off", "noSvgWithoutTitle": "off" }, + "complexity": { + "useLiteralKeys": "off", + "useOptionalChain": "off" + }, "performance": { "noAccumulatingSpread": "off" }, "suspicious": { "noArrayIndexKey": "off", "noExplicitAny": "off" - }, - "complexity": { - "useOptionalChain": "off" } } } diff --git a/index.js b/index.js index a3ed7f8f..ce407f91 100644 --- a/index.js +++ b/index.js @@ -191,15 +191,15 @@ class Replicate { url.searchParams.append(key, value); } - const headers = new Headers(); + const headers = {}; if (auth) { - headers.append("Authorization", `Token ${auth}`); + headers["Authorization"] = `Token ${auth}`; } - headers.append("Content-Type", "application/json"); - headers.append("User-Agent", userAgent); + headers["Content-Type"] = "application/json"; + headers["User-Agent"] = userAgent; if (options.headers) { - for (const [key, value] of options.headers.entries()) { - headers.append(key, value); + for (const [key, value] of Object.entries(options.headers)) { + headers[key] = value; } }