So I have an indeterminate amount of calls I wish to run in parallel in any example I have seen the amount of promises are known from the start.
await Promise.allSettled([someCall(), anotherCall()]);
My issue is I don't know how many promises will be required in the code below I might have 4 delays or 50 delays of various lengths however it does not seem to await for me any thoughts.
let qq = bulk([1,2,3,4,5]);
console.log('last');
async function bulk(array){
const promiseArray = [];
for (const delay of array) {
promiseArray.push(bulkQuery(delay));
}
const valueArray = await Promise.allSettled(promiseArray);
}
async function bulkQuery(delay){
return new Promise((resolve, reject) => {
setTimeout(() => {
console.log(delay);
resolve('foo');
}, delay*1000);
});
}
await Promise.allSettled(array.map(bulkQuery));promiseArrayqq.then(() => console.log('last'));