SUNNY-yl

导航

 

背景

react 前端写接口的时候,发现get请求加了headers之后发出来的请求不通,通过检查,发现写的语法有问题,在此记录下:

post请求

axios post请求时带headers:

axios.post("http://xxx.com/xxx/xxx/xxx?", { 'queslistid': this.kemuid }, { headers: { 'token': Cookies.get('token'), 'platform': 'web' } }
).then((login) => {
  console.log(login)
});

get请求

axios get请求时带headers:

1 axios.get("http://xxx.com/xxx/?", { params: { id: this.kemuid }, headers: { token: Cookies.get('token'), platform: 'web' } }
2 ).then((res) => {
3   console.log(res);
4 });

 参考链接:https://www.cnblogs.com/wolfocme110/p/12075355.html?ivk_sa=1024320u

 

posted on 2022-04-18 10:35  The依依  阅读(3631)  评论(0编辑  收藏  举报