axios合并异步请求
程序员文章站
2022-07-02 12:28:38
...
onMounted(()=>{
//axios合并异步请求
axios.all([getTypeData(),getArticleList()])
.then(axios.spread((typeListRes,articleListRes)=>{
console.log(typeListRes.data,articleListRes.data);
}))
})
const typeList=ref([]);
const articleList=ref([]);
const getTypeData=()=>{
return axios({
url:`${baseURL}/getTypeList`,
method:"get"
})
}
const getArticleList=()=>{
return axios({
url:`${baseURL}/getArticleList`,
method:"get"
})
}