邮差回应:无法从服务器得到任何回应

我试图创build一个待办事项列表的应用程序,并检查与POSTMAN在每一种types的请求。 GET和POST请求正常工作。 但是PUT和DELETE不能按预期工作。

正如预期的意思:这是不显示404既不显示结果,而是显示错误,即无法得到任何答复。

这是我的代码put和delete:

var todos = []; // DELETE /todos/:id app.delete('/todos/:id', function(req,res){ var todoId = parseInt(req.params.id, 10); var matchedTodo = _.findWhere(todos, {id: todoId}); if(!matchedTodo){ res.status(404).send(); }else{ todos = _.without(todos, matchedTodo); res.json(matchedTodo); //console.log(todos); } }); // PUT /todos/:id app.put('/todos/:id', function(req,res){ var todoId = parseInt(req.params.id, 10); var matchedTodo = _.findWhere(todos, {id: todoId}); var body = _.pick(req.body, 'description', 'completed'); var validAttributes = {}; if(!matchedTodo){ return res.status(404).send(); } if(body.hasOwnProperty('completed') && _.isBoolean(body.completed)){ validAttributes.completed = body.completed; }else if(body.hasOwnProperty('completed')){ return res.status(400).send(); } if(body.hasOwnProperty('description') && _.isString(body.description) && body.description.trim().length > 0){ body.description = body.description.trim(); validAttributes.description = body.description; }else if(body.hasOwnProperty('description')){ return res.status(400).send() } _.extend(matchedTodo, validAttributes); res.json(matchedTodo); }); 

现在,我不知道这是一个错误还是什么。