mongoose.set('debug', true)
router.get('/list', (req,res) => {
Insider.find({},{id:1}).then(insdiers => {
if(!insiders) return res.status(400).json({error: "unable to locate insiders"});
res.json(insiders);
}).catch(err => res.status(400).json(err));
});
insdiers
should be insiders
Insider.find()
?
router.get('/list', (req, res) => {
Insider.find({}, {_id: 1}).then(insiders => {
if (!insiders) {
return res.status(400).json({ error: 'unable to find list of insiders' });
}
res.json(insiders);
}).catch(err => res.status(400).json(err));
});
return res.json(insiders)
router.get('/list', (req,res) => {
Insider.find({}, {id: 1}, (err, insiders) => {
if(err){
return res.status(400).json(err);
}
res.json(insiders);
});
});
/:insiderId
being defined higher in the file caused /list
to match it. It was assuming the text 'list' was an objectID.