Skip to content

Commit

Permalink
feat: fetchWithRetry에서 실패 후 1초 대기
Browse files Browse the repository at this point in the history
  • Loading branch information
yeolyi committed Mar 11, 2024
1 parent 31c2ea6 commit 2c1ec87
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions apis/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const fetchWithRetry = async (
if (remain === 0) throw e;

console.error(`fetchWithRetry: ${e} ${url} ${method} ${init}`);
await delay(1000);
return await fetchWithRetry(url, method, init, remain - 1);
}
};
Expand All @@ -82,3 +83,5 @@ const _fetch = async (url: string, method: string, init?: CredentialRequestInit)
return resp;
}
};

const delay = (ms: number) => new Promise((resolve) => setTimeout(() => resolve, ms));

0 comments on commit 2c1ec87

Please sign in to comment.