Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var router = express.Router();
router.get('/getUsers', function(req, res, next) {
var searchQuery = {};
if(req.query.name)
searchQuery = { name: req.query.name };
User.find(searchQuery, function(err, users){
if (err) {
res.status(400);
res.send();
}
console.log("returning all the users.");
res.send(users);
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment