I'm putting together a personal project that I need to login.
the project is in react js and rails API.
to login i am using devise.
the devise by default when you login, it returns the access-token and client in the headers.
but i can't access these tokens in react.
const url = `${process.env.REACT_APP_API_URL}/auth/sign_in`;
const requestOptions = {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(form)
};
const res = await fetch(url, requestOptions).then(res => res.json());
if(res.errors){
for(let i = 0; i<res.errors.length; i++){
setFormErrors(form_errors => [...form_errors, res.errors[i]]);
}
}else{
console.log(res);
// window.location.replace('http://localhost:3002/');
}
I need them to use in future requests to the server.
i'm completely lost in how to go ahead.
I don't know if there's a way to access these tokens in the header.
or suddenly I can change the devise to send this data in the body response.
which is the best option?
help me, thanks