Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript node retry promise.all

function retry(fn, retries=3, err=null) {
  if (!retries) {
    return Promise.reject(err);
  }
  return fn().catch(err => {
      return retry(fn, (retries - 1), err);
    });
}
Comment

node javascript retry promise.all

const axios = require('axios');
  const axiosRetry = require('axios-retry');

  axiosRetry(axios, {
    retries: 3, // number of retries
    retryDelay: (retryCount) => {
      console.log(`retry attempt: ${retryCount}`);
      return retryCount * 2000; // time interval between retries
    },
    retryCondition: (error) => {
      // if retry condition is not specified, by default idempotent requests are retried
      return error.response.status === 503;
    },
  });

  const response = await axios({
    method: 'GET',
    url: 'https://httpstat.us/503',
  }).catch((err) => {
    if (err.response.status !== 200) {
      throw new Error(`API call failed with status code: ${err.response.status} after 3 retry attempts`);
    }
  });
Comment

PREVIOUS NEXT
Code Example
Javascript :: multiplicar celulas js 
Javascript :: get all keys of nested object json data javascript 
Javascript :: verify number of times request was made in cypress 
Javascript :: date change error 
Javascript :: dynamically create html table in javascript 
Javascript :: mindate from another datepicker 
Javascript :: Custom usePagination hook 
Javascript :: adding values for metaboxes in wordpress 
Javascript :: highlight row javascript 
Javascript :: angular 8 input decorator Expected 2 arguments, but got 1. 
Javascript :: invert binary tree js 
Javascript :: A Note about Floats 
Javascript :: multiple counter for loop in javascript 
Javascript :: maxscript saveMaxFile 
Javascript :: random number between 0 and 50 then round to a whole number 
Javascript :: icon with label in react native 
Javascript :: force dom render 
Javascript :: array[-1] not working 
Javascript :: javascript return opposite boolean 
Javascript :: split a table by sertain number of entities javascript 
Javascript :: react load after scrolling 
Javascript :: return axios response from seperate file 
Javascript :: js console 
Javascript :: nice password generator 
Javascript :: I want to enable textbox when checkbox is checked in jquery or javascript 
Javascript :: regular expressiong to indentify bible references in a sentence 
Javascript :: random height fallling object in js 
Javascript :: how to update a state with an array react 
Javascript :: Script test to be oneOf 
Javascript :: mongoose-unique-validator 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =