Hello, I'm trying to do a search on the bank with this code using the mongojs findOne, follow code:
app.get('/detalhesContato/:id', function(req, res){
var id = req.params.id;
console.log(id);
db.contatos.findOne({_id: mongojs.ObjectId(id)}, function(err, doc) {
console.log(err);
res.json(doc);
});
console.log(id)
returns the correct id but at the time of using the findOne
function of this error:
"567a16ba28dee028f4a8ad78 < - id console log
TypeError: Can not read property 'findOne' of undefined at /Users/Michel/Documents/AngularProjects/RodrigoBranasListTelefonica/server.js:48:12 "