This is how I use Angular's $http.get to send parameters to a REST endpoint. It works:
var httpParams = {'myparam1': 'Hello'};
$http.get('http://localhost:8976/my/url', {'params': httpParams}).then(successFunc, failureFunc);
This sends a GET call that is equivalent to the following CURL command:
curl --request GET "http://localhost:8976/my/url?myparam1=Hello"
But now want to send a DELETE request with the same URL and the same parameters. How do I do it? This doesn't work:
var httpParams = {'myparam1': 'Hello'};
$http.delete('http://localhost:8976/my/url', {'params': httpParams}).then(successFunc, failureFunc);
The URL gets hit, but the parameters are not received by the REST endpoint.
For handling RESTful things you should use Angular#$resource which provide delete method on each resource object.And you can configure the params as well during resource configuration and creation.
Using resource,you can have CRUD API without manual configuration.
so,http GET,POST,DELET,PUT method on this resource object
If you want to send DELETE REST manually then better pass the parameter as query string.It does not send the parameter in the body.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With