【发布时间】:2021-11-08 03:36:57
【问题描述】:
我有一个对服务器的授权请求:
axios
.post(
"http://localhost:5000/api/auth/sign-in",
{ ...values },
)
.then((res) => {
const { token } = res.data;
//there I need to save coookie with token that came from server
})
授权成功后,服务器发送token,如何将token保存在带有httpOnly标志的cookie中?
【问题讨论】:
-
您可以使用react-cookie 包。使用起来非常简单。
-
这能回答你的问题吗? How can I set a cookie in react?
标签: reactjs