You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey,
I was trying out the tutorial and didn't have a problem with saving the user/token to localStorage, but I did have trouble pulling the token back. It took me about 3 days to find out it was because the token itself was being stringified, which my backend couldn't interpret.
On the tutorial app.js shows (lines 17-19):
case "LOGIN": localStorage.setItem("user", JSON.stringify(action.payload.user)); localStorage.setItem("token", JSON.stringify(action.payload.token));
Mine worked by doing:
case "LOGIN": localStorage.setItem("token", action.payload.jwt);
I understand saving the user to localStorage is optional, and that worked ok. But stringifying the token caused all sorts of problems.
The text was updated successfully, but these errors were encountered:
Hey,
I was trying out the tutorial and didn't have a problem with saving the user/token to localStorage, but I did have trouble pulling the token back. It took me about 3 days to find out it was because the token itself was being stringified, which my backend couldn't interpret.
On the tutorial app.js shows (lines 17-19):
case "LOGIN": localStorage.setItem("user", JSON.stringify(action.payload.user)); localStorage.setItem("token", JSON.stringify(action.payload.token));
Mine worked by doing:
case "LOGIN": localStorage.setItem("token", action.payload.jwt);
I understand saving the user to localStorage is optional, and that worked ok. But stringifying the token caused all sorts of problems.
The text was updated successfully, but these errors were encountered: