Hello I am wondering is it a good practice to keep the token in the local storage in react js because I read this article https://dev.to/rdegges/please-stop-using-local-storage-1i04 and there they say it is not good to use local storage for sensitive data. Also I am coding a API with a security and session for first time and I will be glad if someone explain me how things must be done right - if there are some resources to read etc. And if it is OK to use token with local storage how this must be done ? how is it saved I saw there are questions asked for saving into (ls) but i can't done this in my request only before that or after that should I use a state variable ? Thanks in advance for any help.
onSubmit = e => {
e.preventDefault();
fetch( `/myresource/customer/${this.state.query}/${this.state.password}`)
.then(res => res.json())
.then((result) => {
console.log(result);
this.setState({
user: result,
password: result
localStorage.setItem('token', ''); <-- Here is not legal to set the token value where should it be saved.
}
);
}
)
this.setState( { welcomeMsg: 'Hello, ' } );
}