I'm using React and using fetch to send a request to the server:
fetch("http://localhost:8001/api/login", {
method: 'post',
headers: {
"Content-type": "application/x-www-form-urlencoded; charset=UTF-8"
},
body: 'username=' + this.state.username + '&password=' + this.state.password
})
.then(function (response) {
console.log('Request succeeded with JSON response', data);
console.log(data.headers.toString())
})
.catch(function (error) {
console.log('Request failed', error);
});
This is chrome inspect, it shows that I get JWT token from server My question is how do I access it in my code? I actually need to save it to a variable, there's really no way to do
data.headers.jwt
I'm sorry if this makes no sense, I can clarify if you need.