DEV Community

Discussion on: Javascript fetch, retry upon failure.

Collapse
 
johnnyshrewd profile image
Johnny Shrewd

Perhaps add a check for a value smaller than 1 to avoid the infinite cycle:

try {
 ....
} catch (err) {
     if (retry === 1 || retry < 1) throw err;
          return await this.johnny(arg, retry - 1);
     }
}
Enter fullscreen mode Exit fullscreen mode