我想從我的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錯誤! –