-1
    Promise.all(purchaseOrderUpdate.map((purchaseOrder) => {
      return axiosInstance.put(CreatePOUrl + "/" + purchaseOrder.id.toString() + '?correlationId=1', purchaseOrder)
      .then(response => {
        console.log("say 1st")
      })
    }))
    console.log("say last")

I thought by returning the axiosInstance, it is returning a list of promises which should all be resolved before "say last" is printed.

Thanks

FranktheTank
  • 292
  • 3
  • 9
  • Does this answer your question? [Promise All with Axios](https://stackoverflow.com/questions/52669596/promise-all-with-axios) – Tore Apr 22 '21 at 19:45

1 Answers1

4

Promise.all is itself a promise, so you would still need to either await it, or console.log in it's .then:

Promise.all(purchaseOrderUpdate.map((purchaseOrder) => {
  return axiosInstance.put(CreatePOUrl + "/" + purchaseOrder.id.toString() + '?correlationId=1', purchaseOrder)
  .then(response => {
    console.log("say 1st")
  })
})).then(() => {
    console.log("say last")
});
dave
  • 62,300
  • 5
  • 72
  • 93