How does JS determine that all requests in an asynchronous queue are completed?

the business scenario is like this


[getListA(),getListB(),getListC()]

getDetail()

getDetail can only be executed after getList is completed. How to judge that this queue is completed

idea 1: all requests are rewritten with async and await,

await getListA()

...
await getListC()

await getDetail()

but this will put all requests executed by Synchronize, while getListA (), getListB (), getListC () can be sent at the same time

< hr >

idea 2: add a request completion flag to each List, loop monitor whether all requests are completed, and finish loading detail

< hr >

is there a better way to implement

Mar.18,2022

await Promise.all([getListA(),getListB(),getListC()])

or

let p1 = getListA()
let p2 = getListB()

await p1;
await p2
Menu