此错误消息(标题消息)不时困扰着我。通常,它不会显示,但是有时当用户登录时,程序崩溃并显示该错误。
完整的错误消息在这里: https://i.imgur.com/rFZ0bCg.png
我搜索了Tedious Api,并尝试使用事件requestCompleted,但未成功。
我的Node.js
// Post method of Login
app.post('/Login', urlencodedParser, (request, response) => {
DBConnect.Login(request.body.email, request.body.password, connection, (error, results, fields) => {
if (error) {
console.log("Error: Cannot login: " + error);
response.send("Error Try again");
} else {
if (results.length > 0) {
if (results[0].Email == request.body.email && results[0].Password == (crypto.createHash("SHA256").update(request.body.password).digest("hex"))) {
console.log(results[0].ID);
response.status(200).send(JSON.stringify(results[0].ID));
} else {
response.status(401).send("Login failed: wrong userame or password.");
}
} else {
response.status(401).send("Login failed: wrong userame or password.");
}
}
});
});
我的登录请求;
let Login = (Email, Password, connection, callback) => {
var request = new Request('SELECT Email, Password, ID FROM Users WHERE Email=@Email', function (error, rowCount, rows) {
if (error) {
console.log("request error: " + error);
} else {
results = createResults(rows);
console.log(results[0]);
callback(error, results, null)
}
});
request.addParameter('Email', TYPES.NVarChar, Email);
connection.execSql(request);
}
I except login system to work, but sometimes it throws me that error.