我正在使用axios
。请告诉我为什么我的request header
参数未在请求中传递。这是我的代码
https://www.w3schools.com/howto/howto_js_slideshow.asp
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
参数未在请求标头中传递。
答案 0 :(得分:5)
您必须指定headers
属性:
.get(
"https://125.16.74.160:30208/?cicleCode=undefined&pageNumber=0&pageSize=20&role=ZBM",
{ headers:{ Authorization: "Bearer zad" } }
)
答案 1 :(得分:0)
axios.get("https://125.16.74.160:30208/?cicleCode=undefined&pageNumber=0&pageSize=20&role=ZBM",
{ headers: { Authorization: "Bearer zad" } })
.then(() => {
console.log("---");
})
.catch(e => {
console.log(e);
});