Skip to content

Commit

Permalink
fix: import cross-fetch conditionally
Browse files Browse the repository at this point in the history
  • Loading branch information
soedirgo committed Jun 27, 2022
1 parent 0516093 commit 438755f
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/helper.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import crossFetch from 'cross-fetch'

type Fetch = typeof fetch

export const resolveFetch = (customFetch?: Fetch): Fetch => {
let _fetch: Fetch
if (customFetch) {
_fetch = customFetch
} else if (typeof fetch === 'undefined') {
_fetch = crossFetch as unknown as Fetch
_fetch = async (...args) => await (await import('cross-fetch')).fetch(...args)
} else {
_fetch = fetch
}
Expand Down

0 comments on commit 438755f

Please sign in to comment.