2

I'm trying to get JSON response from server using restangular.

  var baseAccounts = Restangular.one('getAllCustomers');
  baseAccounts.getList().then(function(customers) {
      $scope.myData = customers;
      console.log(customers);
    });

The problem is that I always get the response in following format:

0: Object
1: Object
2: Object
addRestangularMethod: function bound() {
all: function bound() {
allUrl: function bound() {
clone: function bound() {
customDELETE: function bound() {
customGET: function bound() {
customGETLIST: function bound() {

But I would like only structure of pure returned JSON. If could somebody put here example for RestAngular plugin I would be very glad.

Thanks for any help.

3 Answers 3

5

To make things simple you can use Restangular 1.4 and chain the plain() function on the response

baseAccounts.getList().then(function(customers){
 $scope.myDate = customers.plain();

});

Sign up to request clarification or add additional context in comments.

Comments

0

Try this

var baseAccounts = Restangular.one('getAllCustomers');
  baseAccounts.getList().then(function(response) {
      $scope.myData = response.customers;
      console.log(response.customers);
    });

1 Comment

undefined. Structure is here: inorthwind.com/Service1.svc/getAllCustomers
0

I am also looking for an answer to this. I have not found anything better, so I implemented that way.

  var baseAccounts = Restangular.one('getAllCustomers');      
  baseAccounts.getList().then(function(customers) {
    var tmp = [];
    customers.forEach(function(element){
      tmp.push(element);
    });

  $scope.myData = tmp;
  console.log(customers);
});

then the return will be

 0: Object
 1: Object
 2: Object

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.