Skip to content

Commit

Permalink
done ticket
Browse files Browse the repository at this point in the history
  • Loading branch information
HadikaMalik committed May 17, 2024
1 parent bc650f6 commit f22887f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions server/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@ import db from "./db.js";
const router = Router();

router.get("/videos", async (_, res) => {
const result = await db.query("SELECT * FROM videos;");
res.json(result.rows);
try{
const result = await db.query("SELECT * FROM videos;");
res.json(result.rows);
}
catch(error){
console.error("Database connection error:", error);
res.status(500).json({success:false, error: "Could not connect to the database"});
}
});

export default router;

0 comments on commit f22887f

Please sign in to comment.