alonisser
alonisser

Reputation: 12098

Caught in Restangular promises

I've got this code:

var me = Restangular.one('object', 1).get({params:params});

me.then(function (data) {

    $scope.me = data;
    $scope.loadsubobject();
});


$scope.loadsubobject = function () {

    $scope.me.getList("subobject")
    .then(function(subobject) {
    //the code never gets here
            console.log('loaded subobjects', subobjects);
            $scope.subobjects = $scope.subobjects.concat(subobject.results);

            if (data.next){
                $scope.next = data.next;
            }
      },function(response){
       console.log('Error with response:', response.status)
        });

when I try to debug the code It seems that after calling the $scope.me.getList("subobject")It returns to the first thenand never getting to the second then, the one that actually process the subobjects I need.

Any clue out of call back hell?

I verified that the server does return the correct answer How can I fix that? be glad for help with this

Upvotes: 1

Views: 939

Answers (1)

alonisser
alonisser

Reputation: 12098

turned out to be a completely different issue, the json returned wasn't "flat", so I need to use a responseExtractor as explained here

Upvotes: 2

Related Questions