-
-
Notifications
You must be signed in to change notification settings - Fork 235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
异步任务:依次发送3次网络请求,拿到服务器数据 #172
Comments
|
同时请求可以换种优雅的方式写法: const p1 = () => new Promise((resolve) => setTimeout(() => {
resolve("p1");
}, 1000))
const p2 = () => new Promise((resolve) => setTimeout(() => {
resolve("p2");
}, 1000))
const p3 = () => new Promise((resolve) => setTimeout(() => {
resolve("p3");
}, 1000))
const fn = async () => {
const r1 = p1()
const r2 = p2()
const r3 = p3()
const res1 = await r1
const res2 = await r2
const res3 = await r3
console.log(res1, res2, res3)
} |
这个应该是实现的promise.all的功能吧 貌似题目要求是要依赖上一个请求的结果 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No description provided.
The text was updated successfully, but these errors were encountered: