6
I am trying to pass a parameter to my DELETE request, I tried to do the following:
Use in the same way I use in GET (where it works normal).
app.delete('/contatos', function(req, res){
var obj = req.body;
console.log(obj);
});
But on the island of Nodejs this .log()
prints only {}
.
I also tried this way (found in Soen):
app.delete('/contatos',function(req, res){
var obj = req.body.data;
console.log(obj);
});
But the same thing happened.
Maybe the DELETE implementation is different from GET and POST and I ignored some step.
I am requesting the API from Angularjs, with the following service:
angular.module("lista").factory("contatosAPI", function($http){
var _saveContato = function(contato){
return $http.post("http://localhost:3412/contatos", contato);
};
var _deleteContato = function(contato){
console.log(contato); //Aqui o objeto está normal
return $http.delete("http://localhost:3412/contatos", contato);
};
return {
saveContato: _saveContato,
deleteContato: _deleteContato
};
});
In the controller I call the service, this way:
$scope.apagarContatos = function(contato){
contatosAPI.deleteContato(contato);
};
How are you making the requisition?
– Rafael Telles
@Rafaeltelles edited
– Jéf Bueno