jwt config node

Solutions on MaxInterview for jwt config node by the best coders in the world

showing results for - "jwt config node"
Lilly
13 Jul 2019
1/// JWT 
2const jwt = require("jsonwebtoken");
3
4const payload = {
5    user: {
6       id: user.id,
7     },
8  };
9
10/// create a secret key
11// ./config/default.json -> {"jwtSecret": "any_name_key"}
12
13const secret = config.get("jwtSecret");
14
15/// jwt.sign() takes 4 parameters
16jwt.sign(payload, secret, { expiresIn: 360000 }, (err, token) => {
17       if (err) throw err;
18     	res.json({ token });
19});
20
21# DONE ✅
22
queries leading to this page
config jwtjwt config nodejwt config node