`app.post('/loginpage',(req,res) => {
let data=req.body;
fns.join('d7','d5',data).then(rows => {
res.json(rows);
}).catch(err => {
res.json({
message: err
});
})
}); **it is my index.js
我想在响应发送回函数(联接)之后将页面重定向到主页。
**});`
join: (table,table1,data) => {
let userid=data.userid;
let password=data.password;
return new Promise ((resolve,reject) => {
let sql=`SELECT username FROM d7 INNER JOIN d5 ON d7.userid=d5.userid AND d5.userid=${userid} AND d5.password="${password}"`;
db.all(sql,(err,rows) => {
if(!err)
{
if(rows.length){
resolve(Object.assign({
code:1,
},rows[0]));
}
else
{
reject({
code:0,
error:'userid and password not match'
});
}
}
else
{
reject({
code:0,
error:'plz enter valid userid'
});
}
});
});
} **and it is a function(join)**
得到响应后从登录页面转到主页的方式是什么(如果用户有效地可以清楚地访问该帐户,则该用户具有一个帐户)。