I have a VPService.requestQueue
which is an array of objects with the following content:
I need to do something after all promises have been completed so I'm using Promise.all(VPService.requestQueue).then(...)
but its not working.
I tried making an array of both the canceller
and promise
and then calling Promise.all()
on both of then both the console.logs inside this Promise.all()
gets called BEFORE I receive the response from the promise.
//getting an array of the promises from VPService.requestQueue
var requestQueuePromises = VPService.requestQueue.map(function (queue) {
return queue.canceller.promise;
});
//gettin array of cancellers
var requestQueueCancellers = VPService.requestQueue.map(function (queue) {
return queue.canceller;
});
Now use Promise.all() to know when the promises have ended but both console.logs are being printed before my promises results are received.
Promise.all(requestQueueCancellers).then(function () {
console.log("After all cancellers")
});
Promise.all(requestQueuePromises).then(function () {
console.log("After all promises")
});