KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
When sending a request to /customers/41224d776a326fb40f000001 and a document with _id 41224d776a326fb40f000001 does not exist, doc is null and I'm returning a 404 : Controller.prototype.show = function(id, res) { this.model.findById(id, function(err, doc) { if (err) { throw err; } if (!doc) { res.send(404); } return res.send(doc); }); }; However, when _id does not match what Mongoose expects as "format" (I suppose) for example with GET /customers/foo a strange error is returned: CastError: Cast to ObjectId failed for value "foo" at path "_id". So what's this error?
Tags (comma-separated)
Save Edits
Cancel