Node.js Express DELETE route not working -


when trying delete item returns: cannot /posts

routes.js

app.delete('/posts/:id', function(req, res){     console.log("deleting");     post.findbyid( req.params.id, function ( err, post ){         post.remove( function ( err, post ){             res.render('posts.ejs');         });     }); }); 

posts.ejs

<% posts.foreach( function( post ){ %>                 <p><%= post._id %></p>                 <p><%= post.title %></p>                 <p><%= post.content %></p>                 <a href="/posts/<%= post._id %>" method='delete'>delete</a>             <% }); %>     

any pointers appreciated :) thanks

html a element doesn't have method attribute. check legal attributes list. means links get.

if want send delete request using browser option use ajax.


Comments

Popular posts from this blog

Why can rails not find a route created by a helper? -

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -