Getting user data from JWT token

I need to get user data from JWT token and display it on index.ejs for logged in users. I am getting the following error when trying to redirect the user to /posts after user logs in :

ReferenceError: Cannot access ‘token’ before initialization
I think the issue lays in routes/auth.js (line 75) but I am not quite sure how to fix it.
Thanks in advance.

Github repo :

I noticed you used res.header to set the header, although I don’t think something like that exists. Maybe I don’t know about it or it’s depreciated.

Try using this https://expressjs.com/en/api.html#res.set and reply if this works.

Also I saw you’ve not used .gitignore properly ( /node_modules instead of node_modules/)

Ok so I’ve changed res.header to res.set .Now I am getting access denied message.