企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
``` ~~~ /** * 1.安装 npm install jsonwebtoken --save * 2.引用 const jwt = require('jsonwebtoken'); * 3.实例 * // 返回token const payload = { id: user.id, name: user.name, avatar: user.avatar }; const token = jwt.sign(payload, keys.secretOrkey, { expiresIn: 3600 }); * * */ const jwt = require('jsonwebtoken'); const user={ id:'1222', name:'duyanting', avatar:'l love you' }; const payload = { id: user.id, name: user.name, avatar: user.avatar }; const token = jwt.sign(payload, 'qwertyuioopasdfghjklzxcvbnm', { expiresIn: 3600 }); console.log(token); ~~~ ```