79238477

Date: 2024-11-29 22:25:27
Score: 0.5
Natty:
Report link

1.) Be sure to check what System.out.println("Generated JWT token: " + jwt) in your backend returns

2.) In your frontend, can you place console.log("Token set:", jwt) before the setToken(jwt) function and see what it logs?

3.) I am sure the token expected to be passed in the headers in authenticated requests is supposed to be a string type. Be sure what is being logged in number 2 above are strings. Otherwise, extract the token from the object in the frontend and send to your setToken(jwt) function.

4.) After the user logs in, check the value of the token in the localStorage to be sure it's a string. Otherwise, something is wrong in either step 1 or 2.

5.) On a final note, using typescript would help to catch bugs of this nature.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: Ayantunji Timilehin