fetchRetry(url, delay, limit, fetchOptions = {}) {
        return new Promise((resolve, reject) => {
            function success(response) {
                resolve(response);
            }

            function failure(error) {
                limit--;
                if (limit) {
                    setTimeout(fetchUrl, delay)
                    delay = delay * 1.5;
                }
                else {
                    // this time it failed for real
                    reject(error);
                }
            }

            function finalHandler(finalError) {
                throw finalError;
            }

            function fetchUrl() {
                return fetch(url, fetchOptions)
                    .then(success)
                    .catch(failure)
                    .catch(finalHandler);
            }

            fetchUrl();
        });
    }
// retry the fetch a few times with increasing delay to handle ratelimiting erros better
retry the fetch a few times with increasing delay to handle ratelimiting erros better
retry the fetch a few times with increasing delay to handle ratelimiting erros better
fetchRetry(url, delay, limit, fetchOptions = {}) {
        return new Promise((resolve, reject) => {
            function success(response) {
                resolve(response);
            }
            function failure(error) {
                limit--;
                if (limit) {
                    setTimeout(fetchUrl, delay)
                    delay = delay * 1.5;
                }
                else {
                    reject(error);
                }
            }
            function finalHandler(finalError) {
                throw finalError;
            }
            function fetchUrl() {
                return fetch(url, fetchOptions)
                    .then(success)
                    .catch(failure)
                    .catch(finalHandler);
            }
            fetchUrl();
        });
    }
fetchRetry ( url , delay , limit , fetchOptions = { } ) { return new Promise ( ( resolve , reject ) => { function success ( response ) { resolve ( response ) ; } function failure ( error ) { limit -- ; if ( limit ) { setTimeout ( fetchUrl , delay ) delay = delay * 1.5 ; } else { reject ( error ) ; } } function finalHandler ( finalError ) { throw finalError ; } function fetchUrl ( ) { return fetch ( url , fetchOptions ) . then ( success ) . catch ( failure ) . catch ( finalHandler ) ; } fetchUrl ( ) ; } ) ; }
retry the fetch a few times with increasing delay to handle ratelimiting erros better
retry the fetch a few times with increasing delay to handle ratelimiting erros better
// this time it failed for real