Skip to content

Instantly share code, notes, and snippets.

View imraheel's full-sized avatar

Raheel Khan imraheel

View GitHub Profile
@osamaishtiaq
osamaishtiaq / request-retry.js
Created April 15, 2022 00:00
Request retry mechanism in JavaScript
export async function requestWithRetry(requestFunc, errFunc, retryCount = 3) {
try {
return await requestFunc();
} catch (err) {
if (retryCount <= 0) {
errFunc(err);
}
console.log('Request failed, retrying...');
retryCount -= 1;