I'm trying to display a result of a query using node.js express and pug. This is my node.js code
function test(req, res, next) {
var result = con.query("SELECT id FROM users WHERE email = '" + req.body.email + "'")
return result;
}
router.post('/remind/submit', async (req, res, next) => {
try {
var result = await test(req);
res.redirect('/login/remind', { success: result });
}
catch (error) {
console.log(error);
}
})
The problem is that what is displayed is an error in the console:
RangeError [ERR_HTTP_INVALID_STATUS_CODE]: Invalid status code: { success: [Query] }
This is my pug form that sends the request.
form(method="post" action="/login/remind/submit" width="10%").flex-fill
.form-group
p Give us your e-mail address and we will send you a new password.
p= success
.form-group
label E-mail
input(type="text" name="email").form-control
button(type=submit).btn.btn-primary Send
Right now i'm not displaying the response. Im trying to get it to work and redirect me correctly.