How to chain a Promise.all with other Promises?

女生的网名这么多〃 提交于 2019-12-03 04:24:23

Just return Promise.all(...

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

I know it's an old thread, but isn't

() => {return Promise.all([getPromise2(), getPromise3()]);}

a little superfluous? The idea of fat arrow is that you can write it as:

() => Promise.all([getPromise2(), getPromise3()])

which makes the resulting code somewhat clearer:

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

Anyway, thanks for the answer, I was stuck with this :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!