Phoenix Praveen
Phoenix Praveen

Reputation: 1

How to access javascript object inside another object

enter code hereHow to access objects in Javascript This is the Object trying to Access

This is the Code

Its returning 'UNDEFINED' why? It may be silly. please help me im new.

CODE :

    app.controller("myCtrl", function($scope,Restangular) {
      Restangular.setBaseUrl('http://localhost:8080/StrutsREST/api');
      var arr=Restangular.all('interfaces').doGET();
      var obj=arr.$object;
      console.log(obj.A1);  
    });

Upvotes: -4

Views: 88

Answers (1)

Yasar Whizz
Yasar Whizz

Reputation: 17

As you are doing API call which is async you need to handle it as Promise by using .then statement

Restangular.all('interfaces').getList().then(function(data) {
    console.log(data.A1);
})

Upvotes: 0

Related Questions