关于 js 并发请求数据的问题

const ids = [1, 2, 3]
const resArr = []
// 1
ids.forEach(id => api(id).then(res => resArr.push(res))
// 2
Promise.all(ids.map(id => api(id).then(res => resArr.push(res))))
原文地址:https://www.cnblogs.com/shiyunfront/p/14607101.html