Skip to content

Commit

Permalink
chore: simplify fetch replacement
Browse files Browse the repository at this point in the history
  • Loading branch information
ctjlewis committed Jun 22, 2023
1 parent 74271da commit b4e9d8f
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/lib/backoff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,14 @@ export const fetchWithBackoff = async (
maxRetries: 7
}
) => {
let _fetch: Fetch | undefined = fetch;

if (!_fetch) {
if (!fetch) {
const { default: nodeFetch } = await import("node-fetch");
_fetch = nodeFetch;
fetch = nodeFetch;
}

for (let i = 0; i <= maxRetries; i++) {
try {
const response = await _fetch(input, init);
const response = await fetch(input, init);

if (!response.ok) {
const errorData = await response.json();
Expand Down

1 comment on commit b4e9d8f

@vercel
Copy link

@vercel vercel bot commented on b4e9d8f Jun 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.