Skip to content

Instantly share code, notes, and snippets.

@abhiaiyer91
Created November 13, 2018 20:47
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/23e1adcb8407ef4282a2f95aa282ee97 to your computer and use it in GitHub Desktop.
Save abhiaiyer91/23e1adcb8407ef4282a2f95aa282ee97 to your computer and use it in GitHub Desktop.
/** rest of code above **/
server.post("/create/draft", async (req, res) => {
const { title, authorId } = req.body;
// Use the createPost API from prisma client
try {
const draftPost = await prisma.createPost({
title,
author: {
connect: {
id: authorId
}
}
});
return res.send(draftPost).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