My code is below.
The error I am getting is in a query statement that contains an UPDATE statement.
Why do I get an ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE email = '[email protected]'' at line 1?
controller
...
exports.login = (req, res, next) => {
const { email, password } = req.body;
const secretKey = req.app.get('jwt-secret');
let sql = `SELECT * FROM user WHERE email = ?`;
User.query(sql, [email], (err, result) => {
...
if (result[0] === undefined || result[0].password !== encrypted) {
res.status(300).send('ID, PS check plz');
} else {
const token = jwtSign(secretKey, result[0].userId, email);
sql = `UPDATE user SET token = ? WHERE email = ?`;
User.query(sql, [token, email], (err, result) => {
console.log(err);
if (err) {
return next(err);
}
...
});
}
});
};
tokenvalue blank?console.log(typeof token);?tokenvalue. Can youconsole.logyou query as shown here stackoverflow.com/questions/41169797/…