执行多个并发请求

AXIOS官方处理方式


const getUserAccount =()=> {
  return axios.get('joynop.com/user/12345');
}
 
const getUserPermissions =()=> {
  return axios.get('joynop.com/user/12345/permissions');
}
 
axios.all([getUserAccount(), getUserPermissions()])
  .then(axios.spread((acct, perms)=> {
    // Both requests are now complete
  }));

async/await 处理

在朋友的帮助下完成了async/await的使用方法
const getUserAccount =()=> {
  return axios.get('joynop.com/user/12345');
}
 
const getUserPermissions =()=> {
  return axios.get('joynop.com/user/12345/permissions');
}

const test= async()=>{

const [a, b] = await Promise.all([
      getUserAccount(),
      getUserPermissions(),
    ]);

}