Answers for "js retry function if error"

0

js retry function if error

function retry(maxRetries, fn) {
  return fn().catch(function(err) { 
    if (maxRetries <= 0) {
      throw err;
    }
    return retry(maxRetries - 1, fn); 
  });
}
Posted by: Guest on March-29-2022

Code answers related to "Javascript"

Browse Popular Code Answers by Language