I'm using JSON Web Tokens for the first time. I'm making a nodejs app using hydra-express framework. I want to use jwt for authentication. As per the docs, I m returning the json token to the front-end.
var tokenData = {
username: req.body.username,
};
var result = {
username: req.body.username,
token: jwt.sign(tokenData, 'secret', { expiresIn: 60 * 60 })
};
res.json(result);
But I don't know how to save this json token to my browser header so that it doesn't get lost and is again sent to the back-end along with the header. How to save it in my browser storage and add it to the request header each time a request is sent to the backend?
via Aman Dwivedi
No comments:
Post a Comment