Skip to content

Instantly share code, notes, and snippets.

@thebergamo
Created December 4, 2015 16:47
Show Gist options
  • Save thebergamo/3c750c9cf2e6a74b226f to your computer and use it in GitHub Desktop.
Save thebergamo/3c750c9cf2e6a74b226f to your computer and use it in GitHub Desktop.
New users controller - get method
// [GET] /user/{id}
UserController.prototype.get = function (request, reply) {
let id = request.params.id;
this.model.findOneAsync({_id: id})
.then((user) => {
if (!user) {
return reply.notFound('User not found for the id: '+id);
}
reply(user);
})
.catch((err) => {
reply.badImplementation(err.message);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment