axios请求

安装

npm install axios --save

 

axios基本使用  

axios({
  url: 'http://123.207.32.32:8000/home/multidata',
  method: 'get'//不写默认get方式
}).then(res => {
  console.log(res.data)
})
axios({//get请求带参数
  url: 'http://123.207.32.32:8000/home/data',
  params: {
    type:'pop',
    page: 1
  }
}).then(res => {
  console.log(res.data)
})

  

并发请求  

axios.all([
  axios('http://123.207.32.32:8000/home/multidata'),
  axios('http://123.207.32.32:8000/home/multidata')
]).then((results) => {//返回results数组
  console.log(results)
})

 

 

 

 

posted @ 2022-11-27 19:43  iTao0128  阅读(74)  评论(0)    收藏  举报