Node.js 节点js jsonwebtoken叹息错误
我一直在尝试使用promise模式生成jwt。然而,我不断地犯这样的错误 {[错误:eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.EYJLBwFfPcI6Inn0AW5New1LlbkBbNbWfPc5JB20ILCjPyXqioje0NTM3MZazmzv9.sw5HwYIVIGBF4UKxDwjLag3kzytefnex5lot6Jvy] 原因:[错误:EYJ0Exaioijkv1qilcjHbGciioijiuzi1Nij9.EYJLBwFpBCI6Inn0AW5New1LlbkBNBwFpBC5JB20ILCjPyXqioje0NTM3MZazmzv9.sw5HwYIVIGBF4UKxDwjLag3kzytefnex5lot6Jvy], 等操作:真} 我使用rsa格式生成public.pem,并尝试了算法:“RS256”,但它也不起作用 错误消息实际上包含我想要的jwt Login.jsNode.js 节点js jsonwebtoken叹息错误,node.js,jwt,json-web-token,Node.js,Jwt,Json Web Token,我一直在尝试使用promise模式生成jwt。然而,我不断地犯这样的错误 {[错误:eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.EYJLBwFfPcI6Inn0AW5New1LlbkBbNbWfPc5JB20ILCjPyXqioje0NTM3MZazmzv9.sw5HwYIVIGBF4UKxDwjLag3kzytefnex5lot6Jvy] 原因:[错误:EYJ0Exaioijkv1qilcjHbGciioijiuzi1Nij9.EYJLBwFpBCI6Inn0AW
var express = require('express'),
router = express.Router(),
rootPath = require('app-root-path'),
User = require(rootPath+'/app/models/user'),
authConfig = require(rootPath + '/config/auth'),
jsonwebtoken = require('jsonwebtoken'),
Promise = require('bluebird'),
jwtSign = new Promise.promisify(jsonwebtoken.sign);
router.post('/',function(req,res,next){
//if body is not empty
if(req.body==='undefined' && !req.body ){
res.status(500).send("Invalid register");
}
//find user from db
var newUser;
User.findOne({email : req.body.email},'email').then(function(user){
newUser = user;`enter code here`
return jwtSign({email:user.email},authConfig.getAuthElement('publicKey'),{ algorithm: 'HS256'});
}).then(function(token){
newUser.access_token = token;
newUser.save();
res.json({data:newUser});
}).catch(function(error){
console.log(error);
res.status(500).send(error);
});
});
module.exports=路由器
请给我一些建议