我正在尝试通过href:
在我的模板中发送POST请求 <% 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>
<% } %>
我正在我的server.js处理此链接:
app.post('/animal/destroy/:id', function (request, response)
{
Animal.remove({ _id: request.parmas.id }, function (err)
{
response.redirect('/');
})
})
点击链接后,我收到以下错误:
Cannot GET /animal/destroy/<id>