From 2b59f1066d8bee13244ae743f7d01f1d1298c7b1 Mon Sep 17 00:00:00 2001 From: Zeliha Pala Date: Sat, 25 May 2024 18:33:56 +0100 Subject: [PATCH] post videos bug related to database (rating column configuration which is "not null") fixed, ratings added to post endpoint --- server/api.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/api.js b/server/api.js index ec7bccbc66..58e750ddd8 100644 --- a/server/api.js +++ b/server/api.js @@ -15,7 +15,7 @@ router.get("/videos", async (_, res) => { }); router.post("/videos", async (req, res) => { - const { title, src } = req.body; + const { title, src, rating } = req.body; if (!title) { return res.status(422).json({ message: "Title field is required" }); @@ -26,8 +26,8 @@ router.post("/videos", async (req, res) => { try { const result = await db.query( - "INSERT INTO videos (title, src) VALUES ($1, $2) RETURNING id", - [title, src] + "INSERT INTO videos (title, src, rating) VALUES ($1, $2, $3) RETURNING id", + [title, src, rating] ); const newVideoId = result.rows[0].id;