我想从我的bd中删除一行恢复id。但是没有任何东西被删除。我在http中发送了id。 我没有错误代码,但我有一个印象,服务器端它不检索我发给他的ID。我无法恢复在我的服务器Express Js删除我的BD
我在我的服务代码角:
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;
}
我在我的服务器代码快递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]);
}
如果我添加: router.delete( '/待办事项',函数(REQ,RES){ VAR updatePromise = service.removeTodoList(req.body); updatePromise.catch(function(){ res.sendStatus(500); }); updatePromise.then(function(rows){ res.sendStatus(200); }); }); 我是404错误! –