Skip to content

Instantly share code, notes, and snippets.

@yamikuronue
Last active October 16, 2015 18:13
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 yamikuronue/9f24f09f82ceec882227 to your computer and use it in GitHub Desktop.
Save yamikuronue/9f24f09f82ceec882227 to your computer and use it in GitHub Desktop.
getGame: (req, res) => {
if (!req.params.id) {
res.status(501).send({error: 'Missing ID'});
return;
}
return dao.getGame(req.params.id).then((data) => {
if (Array.isArray(data)) {
data = data[0]; //Only the first game
}
if (!data) {
res.status(404);
return;
}
data.canonical = `/api/game/${data.id}`;
res.send(data);
}).catch((err) => {
//TODO: logging errors
res.status(500).send({error: `Database error: ${err}`});
/*What do I put here to make "we passed, yay" appear on the console? */
});
}
getGame(res, req).then(console.log("we passed yay"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment