The delete button is only visible if the signed-in user and postedBy user are the same for the specific post being rendered. For the post to be deleted from the database, we will have to set up a delete post API that will also have a fetch method in the frontend to be applied when delete is clicked.
mern-social/server/routes/post.routes.js:
router.route('/api/posts/:postId') .delete(authCtrl.requireSignin, postCtrl.isPoster, postCtrl.remove)
The delete route will check for authorization before calling remove on the post, by ensuring the authenticated user and postedBy user are the same users. The isPoster method checks if the signed-in user is the original creator of the post before executing the next method.
mern-social/server ...