Monday 24 July 2017

Send ObjectId using jwt.sign error

I've been trying to send the user object id when a user logs i via the logintoken so that i can access it in my index.html using: but it keeps giving a error: SyntaxError: Invalid shorthand property initializervar token = jwt.sign({ username: user.username, email:user.email, id = user._id }, secret, { expiresIn: '24h' }); // Logged in: Give user tokenWhen this token is assigned to the user, how do i get the user object id in the index.html? This should follow when i run the following code, right?// Route to get the currently logged in user router.post('/me', function(req, res) { res.send(req.decoded); // Return the token acquired from middleware });

Submitted July 24, 2017 at 07:42PM by Sirzorre

No comments:

Post a Comment