Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/minsion/promise-all-await
promise.all解决多个await互不相干的接口请求
https://github.com/minsion/promise-all-await
Last synced: about 1 month 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 (7 months ago)
- Default Branch: main
- Last Pushed: 2024-06-25T08:41:44.000Z (7 months ago)
- Last Synced: 2024-06-25T10:18:12.192Z (7 months ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 0
- 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)
}
}```