I have been struggling with this for awhile and just cant get it figured out. My delete button is sending the server a GET /delete? and returning a 304
This is also my first post here and i di try and figure this out for a few hours first... but i am new to programming in general and would appreciate any guides or help you can offer - thanks!
I have 3 files at play here: addpost.js, addpost.ejs, and app.js
This is in addpost.js
router.delete('/delete', function (req, res){
Comment.findById(req._id, function (err, Comment){
console.log('DELETE removing ID: ' + comments._id)
res.format({
html: function(){
res.redirect('/');
},
json: function(){
res.json({message: 'deleted',
title : comments});
}
});
});
});
This is in app.js
app.use('/delete', addpost)
This is in addpost.ejs
<div class ="form">
<form method="delete" action="/delete">
<div class="delete">
<button class="btn btn-raised btn-warning" type="submit">Delete</Button>
</form>
</div>