-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NW6 | Zeliha Pala | Full-Stack-Project | Week-2 | DELETE-A- Video-Recommendation #34
Conversation
✅ Deploy Preview for watch-next-cyf ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done Zeliha!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work, one minor gripe
router.delete("/videos/:id", async (req, res) => { | ||
const videoId = req.params.id; | ||
|
||
try { | ||
await db.query("DELETE FROM videos WHERE id = $1", [videoId]); | ||
res | ||
.status(200) | ||
.json({ success: true, message: "Video deleted successfully" }); | ||
} catch (error) { | ||
res | ||
.status(500) | ||
.json({ success: false, error: "Failed to delete the video" }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good. I appreciate the use of appropriate HTTP error codes and paramatized queries.
onDelete(videoId); | ||
}) | ||
.catch((error) => { | ||
console.error(error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Console.error is not a great solution here. The average user never looks in the console so you should make a habit of using a visible error like a alert()
No description provided.