How To Send Delete Request To Server With Json Data Using Angularjs?
I have to send a http DELETE request to a server. The type has to be JSON, and the object looks like this: { 'id': 'value'} My first approach was the following code, but so far it
Solution 1:
As @KevinB pointed out, config is the second parameter.
var obj = { "id": "value"};
var config = { data: JSON.stringify(obj) };
$http.delete('http://blabla/server/house', config).success(function(data) {
console.log(data);
//Redirect to index.html
$location.path('/');
});
Solution 2:
$http({
method: 'DELETE',
url: 'http://blabla/server/house',
data: JSON.stringify({
'id': 'value'
})
}).success(function (results) {
console.log(results);
//Redirect to index.html
$location.path('/');
});
Post a Comment for "How To Send Delete Request To Server With Json Data Using Angularjs?"