http://chuansong.me/n/394228451820
同時執行多個請求
axios.all([
axios.get('https://api.github.com/xxx/1'),
axios.get('https://api.github.com/xxx/2')
])
.then(axios.spread(function (userResp, reposResp) {
// 上面兩個請求都完成后,才執行這個回調方法
console.log('User', userResp.data);
console.log('Repositories', reposResp.data);
}));
當所有的請求都完成后,會收到一個數組,包含着響應對象,其中的順序和請求發送的順序相同,可以使用 axios.spread 分割成多個單獨的響應對象