Created
December 4, 2015 16:47
-
-
Save thebergamo/3c750c9cf2e6a74b226f to your computer and use it in GitHub Desktop.
New users controller - get method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// [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