Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

Vinllen Chen


To be a better coder

How to get return code and return data from Restangular

  Use response.status to get return code when failed and use response.plain() or Restangular.stripRestangular(response) to get return clean data without any Restangular methods. Pay attention that the .plain() attribution is supported after 1.4.0 version of Restangular. Here comes the example:

Restangular.all(xxx).post(cmd).then(function(response) {  
     //console.log(response.plain()); //plain
     //Restangular.stripRestangular(response); //stripRestangular
}, function(response) {
     console.log("Error with status code", response.status);
});

Reference

https://github.com/mgonto/restangular


About the author

vinllen chen

Beijing, China

格物致知


Discussions

comments powered by Disqus