Skip to content
This repository was archived by the owner on Mar 8, 2023. It is now read-only.

Commit 019b676

Browse files
committed
Run custom fetch fn
1 parent 21ccfe7 commit 019b676

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

src/templates/core/fetch/sendRequest.hbs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ async function sendRequest(options: ApiRequestOptions, url: string): Promise<Res
77
if (OpenAPI.WITH_CREDENTIALS) {
88
request.credentials = 'include';
99
}
10-
return await fetch(url, request);
10+
const fetchFn = typeof window.customFetch === 'function' ? window.customFetch : fetch;
11+
return await fetchFn(url, request);
1112
}

src/templates/core/node/sendRequest.hbs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ async function sendRequest(options: ApiRequestOptions, url: string): Promise<Res
44
headers: await getHeaders(options),
55
body: getRequestBody(options),
66
};
7-
return await fetch(url, request);
7+
const fetchFn = typeof window.customFetch === 'function' ? window.customFetch : fetch;
8+
return await fetchFn(url, request);
89
}

test/__snapshots__/index.spec.js.snap

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,8 @@ async function sendRequest(options: ApiRequestOptions, url: string): Promise<Res
219219
if (OpenAPI.WITH_CREDENTIALS) {
220220
request.credentials = 'include';
221221
}
222-
return await fetch(url, request);
222+
const fetchFn = typeof window.customFetch === 'function' ? window.customFetch : fetch;
223+
return await fetchFn(url, request);
223224
}
224225

225226
function getResponseHeader(response: Response, responseHeader?: string): string | null {
@@ -2572,7 +2573,8 @@ async function sendRequest(options: ApiRequestOptions, url: string): Promise<Res
25722573
if (OpenAPI.WITH_CREDENTIALS) {
25732574
request.credentials = 'include';
25742575
}
2575-
return await fetch(url, request);
2576+
const fetchFn = typeof window.customFetch === 'function' ? window.customFetch : fetch;
2577+
return await fetchFn(url, request);
25762578
}
25772579

25782580
function getResponseHeader(response: Response, responseHeader?: string): string | null {

0 commit comments

Comments
 (0)