axios.get 请求附带参数、设置header的方法

12,667 阅读1分钟

return axios.get(url, {
  params: data, //附带参数
  headers: {'authorization': 'xxxxxx'} //设置header信息
}).then((res) => { 
  //then 成功
  console.log("获取到信息")
}).catch((err) => {
  //catch 失败
  console.log("获取信息失败")

});