Is there a way to wait on all promises in a Promise chain? I have discovered the Promise.all() function for waiting on an array of promises, but I couldnt make that work.
I have something that is roughly like this
var returnPromise2;
var returnPromise1 = function1ThatReturnsAPromise.then(
function onSuccess(array) {
console.log("First function finished");
}).then( function (value) {
returnPromise2 = function2ThatReturnsAPromise(value);
});
return [returnPromise1, returnPromise2];
So in my calling code, if i do Promise.all(arrayOfPromises)
I am able to get the value from returnPromise1, but not the 2nd one. The dillema being that at the time of the return, returnPromise2
is still null.
Any tips appreciated on how to approach this.