Search code examples
restangular

how to put param(body) in restangular?


I have api that required parameter in body, so I need to put that values in restangular, I have tried this

function deleteAccount(){
      $log.log(accountIdDelete);
      Restangular.one(apiDeleteAccount).customDELETE(
        undefined,
      [
        {id : accountIdDelete},
        {ContentType:'application/x-www-form-urlencoded'}
      ]).then(function(response){
        $log.log(response);
        var index = vm.account.indexOf(accountIdDelete);
        if (index > -1) vm.account.splice(index, 1);
        $('#deleteAccount').modal('hide');
      });
    }

What I'm trying is basicly tried to delete the data using id, I need that data Id put it in body request so that the api can detect select the data and delete it. but the code above that doesn't pass the value to the server? is there any way to put request body in restangular?


Solution

  • Based on my knowledge and searching on the internet, NgResource and restangular doesnt' support to set body into delete request, the only support for POST request to put data into the body, Correct me if I'm wrong but this is based on this answer : https://stackoverflow.com/a/16203738/2652524