Home > Blockchain >  How to call multiple APIs using axios.all() when one of the endpoints is not working?
How to call multiple APIs using axios.all() when one of the endpoints is not working?

Time:12-23

Suppose I have an array on endpoints and I want to call them using axios.all() but one of the endpoint is down or not working how to get data only from the working endpoints

 const res = await axios.all(BPPs.map(BPPs => axios.get(BPPs)));

  console.log(res);
    const cataLouge = res.map(e => {
      return e.data;
    });
    console.log(cataLouge);

this is my functions which is calling all the endpoints

CodePudding user response:

axios.all() has been deprecated. Instead, use Promise.all() or Promise.allSettled().

There is no way with axios.all() to get other responses if one of the call fails.

  • Related