Skip to content

Commit d000a0a

Browse files
baoshanwolfy1339
andauthoredJul 11, 2022
feat: failover from native fetch to node-fetch (#481)
Co-authored-by: wolfy1339 <4595477+wolfy1339@users.noreply.github.com>
1 parent b18514a commit d000a0a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed
 

‎src/fetch-wrapper.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ export default function fetchWrapper(
2727
let url: string;
2828

2929
const fetch: typeof nodeFetch =
30-
(requestOptions.request && requestOptions.request.fetch) || nodeFetch;
30+
(requestOptions.request && requestOptions.request.fetch) ||
31+
globalThis.fetch ||
32+
/* istanbul ignore next */ nodeFetch;
3133

3234
return fetch(
3335
requestOptions.url,
@@ -115,7 +117,6 @@ export default function fetchWrapper(
115117

116118
return getResponseData(response);
117119
})
118-
119120
.then((data) => {
120121
return {
121122
status,
@@ -124,7 +125,6 @@ export default function fetchWrapper(
124125
data,
125126
};
126127
})
127-
128128
.catch((error) => {
129129
if (error instanceof RequestError) throw error;
130130

0 commit comments

Comments
 (0)
Please sign in to comment.