gpt4 book ai didi

javascript - 为什么请求头没有在 react 中的get请求中传递?

转载 作者:行者123 更新时间:2023-11-30 08:18:45 26 4
gpt4 key购买 nike

我正在使用 axios。你能告诉我为什么我的 request header 参数没有在请求中传递吗?这是我的代码 https://codesandbox.io/s/flamboyant-hertz-j7mmd

 const abc = () => {
axios
.get(
"https://125.16.74.160:30208/?cicleCode=undefined&pageNumber=0&pageSize=20&role=ZBM",
{ Authorization: "Bearer zad" }
)
.then(() => {
console.log("---");
})
.catch(e => {
console.log(e);
});
};

为什么Authorization参数没有在请求头中传递。

enter image description here

最佳答案

您必须指定 headers 属性:

  .get(
"https://125.16.74.160:30208/?cicleCode=undefined&pageNumber=0&pageSize=20&role=ZBM",
{ headers:{ Authorization: "Bearer zad" } }
)

关于javascript - 为什么请求头没有在 react 中的get请求中传递?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57464691/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com