This code is incorrect. Redirect only redirects, I don't think you can pass results through it.
router.post('/form', function(req, res, next){
var student = new StudentModel({
firstName: req.body.firstName,
lastName: req.body.lastName,
});
student.save(function (err) {
if (err) return handleError(err);
db.collection("studentmodels").find().toArray(function(err, result) {
if (err) throw err;
res.redirect('/submitted', { data: result}); -- what can I do here?
});
});
});
Is there a way to redirect and include this information?
I would like to use:
res.render('submitted', { data: result})
But I can't change the URL path