I want to store user access token and userID in local storage and also in the redux store, when a user login. We will receive the access token and userId from the API, when a user login.
Thanks in Advance.
I want to store user access token and userID in local storage and also in the redux store, when a user login. We will receive the access token and userId from the API, when a user login.
Thanks in Advance.
Saving to local storage and setting it to auth header
// Get token
const { token } = res.data;
// Set token to local storage
// Note: Local storage only stores strings
localStorage.setItem("jwtToken", token);
// Set token to Auth header - if you are using axios
axios.defaults.headers.common["Authorization"] = token;