Skip to content

Instantly share code, notes, and snippets.

@NMZivkovic
Created October 8, 2017 18:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NMZivkovic/b35e36076a677ce72d536cde507a656d to your computer and use it in GitHub Desktop.
Save NMZivkovic/b35e36076a677ce72d536cde507a656d to your computer and use it in GitHub Desktop.
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