app.get('/:titless?', function(req, res) { PostDB.prototype.find({title: req.body.titless}, function(error, article_collection) { console.log(article_collection); console.log(error); switch (req.params.format) { case 'json': res.send(documents.map(function(d) { return { title: d.title, id: d._id }; })); break; default: res.send('Format not available', 400); break; } }); });