https://github.com/minsion/promise-all-await
promise.all解决多个await互不相干的接口请求
https://github.com/minsion/promise-all-await
Last synced: 3 months ago
JSON representation
promise.all解决多个await互不相干的接口请求
- Host: GitHub
- URL: https://github.com/minsion/promise-all-await
- Owner: minsion
- Created: 2024-06-14T16:35:14.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-06-25T08:41:44.000Z (about 1 year ago)
- Last Synced: 2025-01-28T05:15:10.596Z (5 months ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## promise-all-await,请求并发问题
promise.all解决多个await互不相干的接口请求```javascript
async function init(id){
const getUser = getUser(id) //请求一
const getPost = getPost(id) //请求二
//用 Promise.all() 同时发送两个请求
try{
const result = await Promise.all([getUser,getPost])
const userRes = result[0]
const postRes = result[1]
console.log(result)
}catch (err){
console.log(err)
}
}```