Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Restangular get clean response object from POST request

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 

            }
like image 761
Narek Mamikonyan Avatar asked Jul 22 '14 10:07

Narek Mamikonyan


1 Answers

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

like image 74
hutingung Avatar answered Nov 16 '22 02:11

hutingung