Skip to content

Instantly share code, notes, and snippets.

@abhiaiyer91
Last active November 14, 2018 02:01
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 abhiaiyer91/a699e81350f5e1a93d1f6caa9ef48f50 to your computer and use it in GitHub Desktop.
Save abhiaiyer91/a699e81350f5e1a93d1f6caa9ef48f50 to your computer and use it in GitHub Desktop.
/** rest of code above **/
server.get("/post/:id", async (req, res) => {
const postId = req.params.id;
// Use the post API from prisma client
try {
const post = await prisma.post({
id: postId
});
const author = await prisma
.post({
id: postId
})
.author();
return res
.send({
...post,
author
})
.status(200);
} catch (e) {
console.error(e);
return res.sendStatus(500);
}
});
/** rest of code below **/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment