axios并发请求
时间:2020-12-24 09:23:38
收藏:0
阅读:43
方式一
<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>
原文:https://www.cnblogs.com/ixtao/p/14182415.html
评论(0)