Here is the restangular code that i am using to delete the object
$scope.delO = (id){
Restangular
.one("footer",id)
.get()
.then((ob)=>{
ob.remove();
}
.catch....
}
The request is being sent properly as i validated in my browser. Here is the express code
route.delete("/",(req,res,next)=>{
console.log(req.body);
helper['del'](req.body._id)
.then(()=>{
res.status(200).end();
})
.catch((err)=>{
res.status(400).json({err:err.message});
});
});
The req.body
comes as empty. According to question here I see it should be in the parameter.
Can someone please explain where am i going wrong ?
Just to remove some confusion here is a screenshot from browser
There can be no data post in DELETE
verb. So in order for the above code to work, i had to modify it as
$scope.delExisting = ()=>{
console.log($scope.form._id);
Restangular
.one("footer/"+$scope.form._id)
.remove()
.then((data)=>{
$scope.list();
})
.catch((err)=>{
console.log("Error");
});
}
And on express taking on the id
of the element to be deleted from the uri
instead.