Skip to content

Commit

Permalink
post videos bug related to database (rating column configuration whic…
Browse files Browse the repository at this point in the history
…h is "not null") fixed, ratings added to post endpoint
  • Loading branch information
zelihapala committed May 25, 2024
1 parent 676ab6e commit 2b59f10
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions server/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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" });
Expand All @@ -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;
Expand Down

0 comments on commit 2b59f10

Please sign in to comment.