@libsql/isomorphic-fetch
Advanced tools
Comparing version 0.2.1 to 0.2.2
19
node.js
@@ -19,5 +19,20 @@ import http from 'http'; | ||
function fetchWithAgentSelection(resource, options = {}) { | ||
return fetch(resource, { agent: agentSelector, ...options }); | ||
let url = resource; | ||
let fetchOptions = options; | ||
if (resource.constructor.name === 'Request') { | ||
url = resource.url; | ||
fetchOptions = { | ||
method: resource.method, | ||
headers: resource.headers, | ||
body: resource.body, | ||
...options | ||
}; | ||
} | ||
const parsedUrl = new URL(url); | ||
const agent = agentSelector(parsedUrl); | ||
return fetch(url, { agent, ...fetchOptions }); | ||
} | ||
export { fetchWithAgentSelection as fetch, _Request as Request, _Headers as Headers}; |
{ | ||
"name": "@libsql/isomorphic-fetch", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"keywords": [ | ||
@@ -47,3 +47,6 @@ "fetch", | ||
"*.d.ts" | ||
] | ||
} | ||
], | ||
"engines": { | ||
"node": ">=18.0.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5176
116