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

apache - Remove .php and add trailing slash in url using htaccess not loading css -

inno setup - TLabel or TNewStaticText - change .Font.Style on Focus like Cursor changes with .Cursor -