Skip to content

Commit

Permalink
Merge pull request #28 from adniyaYousaf/delete-endpoint
Browse files Browse the repository at this point in the history
complete the delete videos endpoint
  • Loading branch information
kayali436 authored May 15, 2024
2 parents d4802b6 + b73b941 commit d5f4f3d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions server/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,16 @@ router.post("/videos", async (req, res) => {
});


router.delete("/videos/:id", async (req, res) => {
const id = req.params.id;

const deletedVideo = await db.query(
`DELETE FROM videos WHERE id='${id}'`
);

deletedVideo
? res.status(200).send({ success: "Deleted the video successfully" })
: res.status(404).send({ error: "Id for the video does not exist" })
})

export default router;

0 comments on commit d5f4f3d

Please sign in to comment.