axios并发请求
方式一
<script>
axios([
axios.get('http://localhost:8080/student/getAllStudent'),
axios.post('http://localhost:8080/student/getStudentById',{id:1})
]).then(res=>{//请求成功相应的是一个数组
console.log(res[0]);
console.log(res[1]);
});
</script>
方式二(使用spread方法处理相应数组结果)
<script>
axios([
axios.get('http://localhost:8080/student/getAllStudent'),
axios.post('http://localhost:8080/student/getStudentById',{id:1})
]).then(
axios.spread((res1,res2)=>{
console.log(res1);
console.log(res2);
})
);
</script>
<script>
axios([
axios.get('http://localhost:8080/student/getAllStudent'),
axios.post('http://localhost:8080/student/getStudentById',{id:1})
]).then(res=>{
console.log(res[0]);
console.log(res[1]);
});
</script>

浙公网安备 33010602011771号