Below I have a post request which a user can make and if the hidden form item with the name _method
is deleted it will make a request to my own server to a different route and delete the post from the database. How should this process work?
app.post("/posts/:id/delete", function(req, res){
if(req.body._method = "delete"){
request({
"method": "delete",
"url": "/posts/"+req.param.id
}, function(err, response, body){
res.redirect("/posts");
});
}
});
app.delete("/posts/:id", function(req, res){
//delete it from the database
res.redirect("/posts");
});