Skip to content

Commit

Permalink
fix: use @supabase/node-fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
soedirgo committed Aug 22, 2023
1 parent b2e3486 commit 4c291ae
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 88 deletions.
144 changes: 60 additions & 84 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"docs:json": "typedoc --json docs/v2/spec.json --entryPoints src/index.ts --entryPoints src/packages/* --excludePrivate --excludeExternals --excludeProtected"
},
"dependencies": {
"cross-fetch": "^3.1.5"
"@supabase/node-fetch": "^2.6.13"
},
"devDependencies": {
"@types/jest": "^26.0.13",
Expand Down
7 changes: 4 additions & 3 deletions src/lib/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ export const resolveFetch = (customFetch?: Fetch): Fetch => {
if (customFetch) {
_fetch = customFetch
} else if (typeof fetch === 'undefined') {
_fetch = async (...args) => await (await import('cross-fetch')).fetch(...args)
_fetch = async (...args) => await (await import('@supabase/node-fetch' as any)).fetch(...args)
} else {
_fetch = fetch
}
return (...args) => _fetch(...args)
}

export const resolveResponse = async () => {
export const resolveResponse = async (): Promise<typeof Response> => {
if (typeof Response === 'undefined') {
return (await import('cross-fetch')).Response
// @ts-ignore
return (await import('@supabase/node-fetch' as any)).Response
}

return Response
Expand Down

0 comments on commit 4c291ae

Please sign in to comment.