Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in stringifying token #6

Open
dekadekadeka opened this issue Dec 10, 2019 · 1 comment
Open

Error in stringifying token #6

dekadekadeka opened this issue Dec 10, 2019 · 1 comment

Comments

@dekadekadeka
Copy link

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.

@samie820
Copy link
Owner

@dekadekadeka my apologies for the late reply, I've been AWOL. Thanks for the feedback. From your suggestion should I change the code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants