0
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');
}
});
}
});
因此,本帖子令牌auth我如何从auth获取令牌以将其发布到localstorage客户端? 我如何定义的令牌,它CUS只设置能把我将令牌保存到本地存储
Uncaught ReferenceError: token is not defined
它没有帮助,我需要帮助获取发布的数据,然后将其设置为本地存储。未捕获的ReferenceError:令牌未定义 – Infinito1337