1

I am dynamically executing API callouts using promise all , but I want to control the order of execution of the callouts.

So in the code below, I want callout2 to wait until callout1 is complete and 3 to wait for 2.

dataMap = [callout1, callout2, callout3]
const newMap = dataMap((x) =>{

        req = axios.post(url, {
            "query": x
        })      
    return req;
});


Promise.all(promiseArray)
.then( (val) => {
    console.log(val[0]);
    console.log(val[1]);
    console.log(val[2]);
})
.catch( (error) => console.log('error' + error))
  • 1
    Do you want subsequent callout to not execute if the prior one fails? If no, then Promise.all() is not what you should use. – Sujit Kumar Singh Jun 12 '19 at 13:12
  • 1
    I added [similar question](https://stackoverflow.com/questions/47693389/synchronous-way-of-handling-asynchronous-function-two-level-deep) but with different requirement. You can use logic mentioned in the question. – Sujit Kumar Singh Jun 12 '19 at 13:16

0 Answers0