【发布时间】:2017-09-22 14:42:36
【问题描述】:
app.post('/auth', function(req,res){
console.log("post got", req.body)
if (req.body.username && req.body.password) {
db.get("select * from user where username='"+req.body.username+"' and password='"+req.body.password+"';", function(err, row){
console.log(row)
if (row && row.username == req.body.username && row.password == req.body.password) {
var data = req.body;
var token = jwt.sign(data, 'shhhhh11');
res.end(JSON.stringify({
token: token
}));
} else {
res.end('authentication unsuccsessful');
}
});
}
});
所以这将令牌发布到身份验证我如何从身份验证获取令牌以将其发布到本地存储客户端? 我如何为它定义令牌,因为只需设置它就可以了
Uncaught ReferenceError: token is not defined
【问题讨论】: