Created
November 13, 2018 21:19
-
-
Save abhiaiyer91/d23a2cb04aa3548622610937cc6710f7 to your computer and use it in GitHub Desktop.
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
/** rest of code above **/ | |
server.get("/posts", async (_req, res) => { | |
// Use the posts API from prisma client | |
try { | |
const posts = await prisma.posts({ | |
where: { | |
published: true | |
} | |
}); | |
return res.send(posts).status(200); | |
} catch (e) { | |
console.error(e); | |
return res.sendStatus(500); | |
} | |
}); | |
server.get("/drafts", async (_req, res) => { | |
// Use the posts API from prisma client | |
try { | |
const posts = await prisma.posts({ | |
where: { | |
published: false | |
} | |
}); | |
return res.send(posts).status(200); | |
} catch (e) { | |
console.error(e); | |
return res.sendStatus(500); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment