axios 获取请求头没有给出写数据响应

问题描述

下面的代码给出了错误的响应,但是在邮递员发送这个带有标头 id = 2 的 get 请求时给出了正确的数据。为什么会这样?

var id =2;
axios.get('http://127.0.0.1:3333/orders/',{ headers: {
        "id" : id      }
    })

上面的代码给出了错误的响应,但是在邮递员发送这个带有标头 id = 2 的 get 请求时给出了正确的数据。为什么会这样?

rawHeaders: [
      'Host','127.0.0.1:3333','Connection','keep-alive','user-id','2','Accept','application/json,text/plain,*/*','sec-ch-ua-mobile','?0','User-Agent','Mozilla/5.0 (Macintosh; Intel Mac OS X 11_0_1) AppleWebKit/537.36 (KHTML,like Gecko) Chrome/88.0.4324.150 Safari/537.36','sec-ch-ua','"Chromium";v="88","Google Chrome";v="88",";Not A Brand";v="99"','Origin','http://localhost:8080','sec-fetch-site','cross-site','sec-fetch-mode','cors','Sec-Fetch-Dest','empty','Referer','http://localhost:8080/','Accept-Encoding','gzip,deflate,br','Accept-Language','en-GB,en-US;q=0.9,en;q=0.8'
    ]```

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)