From 34b3fefaddd165b649c53e140f6b749c18943d26 Mon Sep 17 00:00:00 2001 From: Mateja Date: Mon, 3 May 2021 17:44:38 +0200 Subject: Add delete option on every post. --- controllers/post.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'controllers') diff --git a/controllers/post.js b/controllers/post.js index 7c66dec..d879fcc 100644 --- a/controllers/post.js +++ b/controllers/post.js @@ -25,6 +25,10 @@ module.exports = { 'text': req.body.text }); newPost.save().then(() => res.redirect('/')); + }, + + destroy(req, res) { + Post.findByIdAndRemove(req.params.id).then(() => res.redirect('/')); } }; -- cgit v1.2.3