【发布时间】:2021-01-21 02:44:42
【问题描述】:
我在发送适当的凭据时从 React 中的 fetch 方法获取令牌,但我不知道如何将 JWT 令牌存储在 cookie 中,后来重用它。下面是代码块:
fetch('http://localhost:5000/api/authenticate/login', {
method: 'POST',
headers: {'Content-type': 'application/json'},
body: JSON.stringify(loginInfo),
}).then(function (response) {
return response.json();
}).then(function (json) {
alert(json.token);
}).catch(function (ex) {
console.log("parsing failed", ex);
});
【问题讨论】: