Przekaż wywołanie zwrotne do report.save
i zadzwoń do res.redirect
stamtąd:
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);
});
});
});