(input: RequestInfo | URL, init: RequestInit & { timeout?: number } = {})
| 4 | const nativeFetch = globalThis.fetch.bind(globalThis); |
| 5 | |
| 6 | export function fetch(input: RequestInfo | URL, init: RequestInit & { timeout?: number } = {}): Promise<Response> { |
| 7 | if (__DEV__) { |
| 8 | console.log('fetch wrapper: ', input, init); |
| 9 | } |
| 10 | const { timeout = DEFAULT_TIMEOUT, ...rest } = init; |
| 11 | const controller = new AbortController(); |
| 12 | const timer = setTimeout(() => controller.abort(), timeout); |
| 13 | return nativeFetch(input, { ...rest, signal: controller.signal }).finally(() => clearTimeout(timer)); |
| 14 | } |
no outgoing calls
no test coverage detected