Skip to content

Instantly share code, notes, and snippets.

@laser
Created December 31, 2014 18:32
Show Gist options
  • Save laser/b66f3099b61af49286d7 to your computer and use it in GitHub Desktop.
Save laser/b66f3099b61af49286d7 to your computer and use it in GitHub Desktop.
n
expressRouter.get("/api/ledgers/:id", function(req, res) {
UserService.getLedgerById(req.params.id, function(err, ledger) {
if (err) {
res.status(404).json({"message": "Not Found"});
}
else {
res.status(200).json(ledger);
}
});
});
expressRouter.patch("/api/users/:id", function(req, res) {
UserService.getUserById(req.params.id, function(err, user) {
if (err) {
res.status(404).json({"message": "Not Found"});
}
else {
UserService.updateUser(id, req.body, function(err, user) {
if (err) {
res.status(400).json({"message": "Invalid data provided"});
}
else {
res.status(200).json(user);
}
});
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment