Geef een terugbelverzoek door aan report.save
en bel res.redirect
vanaf daar:
router.post('/get/:faultId/new_comment', function(req, res, next) {
var commenter = req.body.first_name + " " + req.body.last_name;
var comment = req.body.new_comment_text
var datetime = Date.now();
var comment_object = commentCreate(commenter, comment, datetime);
FaultReport
.findOne({
'_id': req.params.faultId
})
.exec(function(err, report) {
if (err) return console.error(err);
report.comment.push(comment_object);
report.save(function(err) {
res.redirect('/api/get/' + req.params.faultId);
});
});
});