tweaking and adding homepage with trending and so on
This commit is contained in:
@@ -11,6 +11,9 @@ router.get('/:id', async (req, res) => {
|
||||
const post = await db.query(`SELECT * FROM posts WHERE id = "${id}"`);
|
||||
|
||||
if(post.length == 0) return res.status(400).json({error: "Post does not exist"});
|
||||
else {
|
||||
const viewPost = await db.query(`UPDATE posts SET viewcount += 1 WHERE id = "${postId}"`);
|
||||
}
|
||||
|
||||
res.status(200).json({post});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user