1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| let arr = [ { url: 'xxx', data: {} }, { url: 'xxx', data: {} }, { url: 'xxx', data: {} }, { url: 'xxx', data: {} }, { url: 'xxx', data: {} }, { url: 'xxx', data: {} }, { url: 'xxx', data: {} } ] async function SubmitMsg(datas, count) { while (datas.length > 0) { let urls = datas.splice(0, count) let ret = await Promise.all(urls.map(getData)) console.log(ret);
} }
function getData({ url, data }) { return axios.post(url, data) }
SubmitMsg(arr,2)
|
v1.5.2