Sam
08/28/2021, 2:07 AMapp.delete('/posts/:id', deletePost);
export const deletePost = async (req: Request, res: Response) => {
const { id }: { id?: number } = req.params;
const post = await prisma.post.delete({
where: {
id: Number(id),
},
})
res.json(post)
};
Now I'm trying to link it with the <PostTable> page... So I have a PostList.ts page, which calls fetch in a UseEffect and gets all the posts then passes it to <PostTable posts={posts}>
So in my PostTable.ts file, I have a posts.map () and then on the delete button, I'm trying to figure out how to delete it
I'm really confused if I need to call useEffect, deletePost (which doesnt work), and then how do I update the page? Should I pass the setPosts from PostList to PostTable? Not sure if I need to call prisma or update the posts using setPostsRyan
08/30/2021, 5:47 AMdeletePost give you? Could you log it using try/catch in your handler and check.