javascript - What is a clean way to send a body with DELETE request? -


i need send request body delete requests using $resource

the way see change:

https://github.com/angular/angular.js/blob/master/src/ngresource/resource.js

from

var hasbody = action.method == 'post' || action.method == 'put' || action.method == 'patch'; 

to

var hasbody = action.method == 'post' || action.method == 'put' || action.method == 'patch' || action.method == 'delete'; 

is there better way override this? when alter content type header can do:

$httpprovider.defaults.headers["delete"] = {'content-type': 'application/json;charset=utf-8'}; 

or similar... ive googled maybe ive missed obvious (not first time). in advance.

this works.

$scope.delete = function(object) {     $http({         url: 'domain/resource',         method: 'delete',         data: {             id: object.id         },         headers: {             "content-type": "application/json;charset=utf-8"         }     }).then(function(res) {         console.log(res.data);     }, function(error) {         console.log(error);     }); }; 

Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -