我正在尝试从我的 API 存储身份验证令牌,因此我可以使用它向另一个 API 发出 GET 请求,我的代码如下:
fetch('APIURL', {
method: 'POST',
body: JSON.stringify({
username: currentUser.username,
password: currentUser.password,
}),
})
.then(response => console.log(response))
.then(json => console.log(json))
用户名和密码来自我的表单输入,我已成功发出 POST 请求并在我的浏览器中获取了令牌,但我想将其存储在我的代码中,在此先感谢 :)