7 lines
191 B
JavaScript
7 lines
191 B
JavaScript
export const retry = (toRetry, maxRetries) => {
|
|
let promise = toRetry();
|
|
for (let i = 0; i < maxRetries; i++) {
|
|
promise = promise.catch(toRetry);
|
|
}
|
|
return promise;
|
|
};
|