const sendRequest = async () => {
try {
const response = await axios.post("http://localhost:8080/auth/login", {
username: username,
password: password,
});
console.log(response.data);
const authorizationHeader = response.headers["Authorization"];
if (authorizationHeader) {
localStorage.setItem("token", authorizationHeader);
console.log("Token stored in localStorage.");
} else {
console.log("No Authorization header received.");
}
} catch (error) {
console.log("Error:", error);
}
};
字符串
这是我上面的功能,但即使我看到的标题,我想得到“授权”在两个网络上的 chrome 浏览器和 Postman 我不能得到它。我做错了什么?
1条答案
按热度按时间klh5stk11#
字符串
将标题名称的第一个字母改为小写解决了我的问题