我无法恢复我的服务器Express Js中删除我的BD中的ID

我想从我的bd中删除一行恢复的id。 但是没有任何被删除。我发送在http身份证。 我没有错误代码,但我有一个印象,服务器端它不检索我发送给他的ID。

我的代码在我的服务Angular:

function removeTask(id){ var promise = $http({ method: "DELETE", url: GENERAL_CONFIG.API_ENDPOINT + "todos", data: id }).then(function success(response) { return response.data; console.log(promise) }, function error(response) { //$rootScope.token = ""; //$location.path("/home"); }); console.log(id); return promise; } 

我的代码在我的服务器Express JS:

 Index.js : router.delete('/', function(req,res){ console.log(req.body); var updatePromise = service.removeTodoList(req.body); updatePromise.catch(function(){ res.sendStatus(500); }); updatePromise.then(function(rows){ res.sendStatus(200); }); }); Service.js : todoService.removeTodoList = function removeTodoList (id){ var taskValues = id ; console.log(id); return dbHandler.query('DELETE FROM todolist WHERE id=?;',[taskValues]); } 

我认为你的端点URL是url: GENERAL_CONFIG.API_ENDPOINT + "todos",而在index.js中使用的是router.delete('/', function(req,res){它应该是router.delete('/todos', function(req,res){

使用

 $http({ method: "DELETE", url: GENERAL_CONFIG.API_ENDPOINT + 'todos/' + id }) 

 router.delete('/:id', function(req,res){ console.log(req.params.id); var updatePromise = service.removeTodoList(req.params.id); updatePromise.catch(function(){ res.sendStatus(500); }); updatePromise.then(function(rows){ res.sendStatus(204); }); });