I am trying to send an POST request in my template through an href:
<% if (typeof(errors) != 'undefined'){ %>
<% for (var i in errors){ %>
<h3><% errors[i].message %></h3>
<% } %>
<% } else{ %>
<table border='1'>
<tr>
<th>Name</th>
<th>Actions</th>
</tr>
<% for (var i in animals){ %>
<tr>
<td><a href='/animals/<%= animals[i]._id %>'><%= animals[i].name %></a></td>
<------------This link---------------->
<td><a href='/animal/edit/<%= animals[i]._id %>'>Edit</a> <a href='/animal/delete/<%= animals[i]._id %>'>Delete</a></td>
</tr>
<% } %>
</table>
<% } %>
And I'm handling this link in my server.js:
app.post('/animal/destroy/:id', function (request, response)
{
Animal.remove({ _id: request.parmas.id }, function (err)
{
response.redirect('/');
})
})
When the link clicked, I get the following error:
Cannot GET /animal/destroy/<id>
via JSim
No comments:
Post a Comment