Skip to content

Commit

Permalink
fix: get original fetch from global
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Nov 20, 2020
1 parent 707fba1 commit bd6b3a8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src.runtime/fetch/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ export * from './call'

export type FetchOptions = globalThis.RequestInit & CallContext

export function createFetch (call: CallHandle) {
return async function fetch (input: string | Request, init: FetchOptions): Promise<Response> {
export function createFetch (call: CallHandle, _fetch = global.fetch) {
return async function ufetch (input: string | Request, init: FetchOptions): Promise<Response> {
const url = input.toString()
if (!url.startsWith('/')) {
return fetch(url, init)
return _fetch(url, init)
}
try {
const r = await call({ url, ...init })
Expand Down

0 comments on commit bd6b3a8

Please sign in to comment.