How to chain a Promise.all with other Promises?

后端 未结 2 457
说谎
说谎 2021-02-06 22:58

I want to execute my code in the following order:

  1. Promise 1
  2. Wait for 1 to be done, then do Promise 2+3 at the same time
  3. Final function waits for
2条回答
  •  抹茶落季
    2021-02-06 23:11

    Just return Promise.all(...

    getPromise1().then(() => {
      return Promise.all([getPromise2(), getPromise3()]);
    }).then((args) => console.log(args)); // result from 2 and 3
    

提交回复
热议问题