# 如何使用 async/await 实现 Promise.all 的效果
更多描述
如获取三个用户的信息,使用 Promise.all
的写法
const users = await Promise.all(getUser(1), getUser(2), getUser(3))
那如何不使用 Promise.all
实现以上效果
Issue
欢迎在 Issue 中交流与讨论: Issue 242 (opens new window)
let req1 = () => fetch(`https://github.com/shfshanyue/Daily-Question/issues?page=1&q=is%3Aissue+is%3Aopen`);
let req2 = () => fetch(`https://github.com/shfshanyue/Daily-Question/issues?page=2&q=is%3Aissue+is%3Aopen`);
let req3 = () => fetch(`https://github.com/shfshanyue/Daily-Question/issues?page=3&q=is%3Aissue+is%3Aopen`);
// promise.all
const res = await Promise.all([req1(), req2(), req3()]);
const res1 = req1()
const res2 = req2()
const res3 = req3()
// await
const u1 = await res1
const u2 = await res2
const u3 = await res3