Error handling in Mongoose
A findById
query that doesn't find a match isn't an error at the Mongoose level, so you if you want it treated that way you have to do it yourself:
Submission.findById(req.params.submission_id, function(err, data) { if (err) return next(err); else if (!data) return next(new Error("User not found")); res.send(data);});