I'm trying to get a token by signing in. Here's the code.
db.query('SELECT * FROM users WHERE email = ?', [email], async (error, results) => {
console.log(results);
if( !results || !(await bcrypt.compare(password, results[0].password)) ) {
res.status(401).render('login', {
message: 'Email or Password is incorrect'
})
} else {
const id = results[0].id;
const token = jwt.sign({ id }, process.env.JWT_SECRET, {
expiresIn: process.env.JWT_EXPIRES_IN
});
console.log("The token is " + token);
const cookieOptions = {
expires: new Date(
date.now() + process.env.JWT_COOKIE_EXPIRES * 24 * 60 * 60
),
httpOnly: true
}
res.cookie('jwt', token, cookeOptions);
res.status(200).redirect("/")
}
The error is Error: expiresIn should be a number of seconds or string rep
but I can't seem to figure out what the problem is. Please help