Skip to content

Commit

Permalink
fix: Revert "Merge pull request #175 from supabase/fix/supabase-node-…
Browse files Browse the repository at this point in the history
…fetch"

This reverts commit dc1d067, reversing
changes made to b2e3486.
  • Loading branch information
soedirgo committed Aug 24, 2023
1 parent dc1d067 commit c389915
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 68 deletions.
144 changes: 84 additions & 60 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": {
"@supabase/node-fetch": "^2.6.13"
"cross-fetch": "^3.1.5"
},
"devDependencies": {
"@types/jest": "^26.0.13",
Expand Down
8 changes: 3 additions & 5 deletions src/lib/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,16 @@ export const resolveFetch = (customFetch?: Fetch): Fetch => {
if (customFetch) {
_fetch = customFetch
} else if (typeof fetch === 'undefined') {
_fetch = (...args) =>
import('@supabase/node-fetch' as any).then(({ default: fetch }) => fetch(...args))
_fetch = async (...args) => await (await import('cross-fetch')).fetch(...args)
} else {
_fetch = fetch
}
return (...args) => _fetch(...args)
}

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

return Response
Expand Down
3 changes: 1 addition & 2 deletions test/storageFileApi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import * as fs from 'fs'
import * as path from 'path'
import FormData from 'form-data'
import assert from 'assert'
// @ts-ignore
import fetch from '@supabase/node-fetch'
import fetch from 'cross-fetch'

// TODO: need to setup storage-api server for this test
const URL = 'http://localhost:8000/storage/v1'
Expand Down

0 comments on commit c389915

Please sign in to comment.