Restangular get clean response object from POST request

Narek Mamikonyan picture Narek Mamikonyan · Jul 22, 2014 · Viewed 8.2k times · Source

I'm trying to use Restangular service, but I have gotten one problem which I can't solve. For example I'm doing the POST request and I want to get clean response Object, but in my response Object wrapped all Restangular methods, I know may be it's a feature, but I need my clean response :))

 this.Restangular.one("auth").post("login",data).then(function(resp){
                console.log(resp);
                // in response object wrapped all Restangular methods 

            }

Answer

hutingung picture hutingung · Jul 22, 2014

You can get the plain element using .plain() from response

 this.Restangular.one("auth").post("login",data).then(function(resp){
      console.log(resp.plain());
      //Returns the plain element received from the server without 
      //any of the enhanced methods from Restangular. 
     //It's an alias to calling Restangular.stripRestangular(elem)
 }

You need to use Restangular version 1.4.0

Plunkr - http://plnkr.co/edit/qDAyPqywC27in9wnlAHF