How run async / await in parallel in Javascript

后端 未结 6 975
没有蜡笔的小新
没有蜡笔的小新 2020-11-30 17:16

Finally async/await will be supported in all major browser soon except IE. So now we can start writing more readable code with async/<

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-30 18:10

    If you're ok with the fail-fast behavior of Promise.all and the destructuring assignment syntax:

    const [userResponse, postsResponse] = await Promise.all([
      fetchUserAsync(),
      fetchPostsAsync(),
    ]);
    

提交回复
热议问题