How to access javascript object inside another object

79 Views Asked by At

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);  
    });
1

There are 1 best solutions below

0
Yasar Whizz On

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);
})