axios的请求头header设置

1.post方法header设置:

 post方式:

 let {userId,token} ={}
  userId = userId?userId:'';token = token?token:''
  axios.post(url, data,{headers: {userId,token}})

get方式:

let {userId,token} = {};
userId = userId?userId:'';token = token?token:''
 axios.get(this.getUrl(url), {params:data,headers: {userId,token}})

 

posted @ 2020-09-28 17:11  野渡  阅读(19059)  评论(0编辑  收藏  举报