Junior — Senior
Reliable GET request with automatic retry
livecode
Task condition
It is required to implement a function that takes a URL string, performs an asynchronous GET request to this resource using fetch, and returns the obtained JSON. In case of any error, the request should automatically retry up to five times. If after all attempts the data is still not received, the function should reject with the error "The specified URL is unavailable".
function fetchWithRetry(endpoint) {
// your code here
}
fetchWithRetry(url)
.then(res => console.log(res))
.catch(err => console.error(err));