Junior — Senior
Fetch wrapper with automatic retry on failure
livecode
Task condition
It is necessary to implement a wrapper function over fetch that will automatically retry the request in case of an error. The function takes the number of attempts and any other arguments passed to fetch. After each failed attempt, the request should be retried until the remaining attempts become -1 (infinite mode). An example function signature:
async function fetchWithRetry(attempts, ...args) {
return fetch(...args);
}
The function should return the promise received from fetch or throw an error if all attempts are exhausted.