Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 });

Expand Down
7 changes: 4 additions & 3 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@
"useMediaCaption": "off",
"noSvgWithoutTitle": "off"
},
"complexity": {
"useLiteralKeys": "off",
"useOptionalChain": "off"
},
"performance": {
"noAccumulatingSpread": "off"
},
"suspicious": {
"noArrayIndexKey": "off",
"noExplicitAny": "off"
},
"complexity": {
"useOptionalChain": "off"
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down