I'm returning a JSON object via a $http.get. I'm able to get the result set, and it's an array, but when I try to access the object outside the fetch() I'm getting undefined. Not sure what I'm missing, in order to do this, any help is appreciated.
Thanks Jimi.
myObject.fetch().then(function(myData) {
$scope.myData = myData;
});
console.log($scope.myData)
console.logwill be running before the callback function has actually run and set$scope.myDataconsole.log(1)into the callback, and the similar with the number2outside. Run and see results. Thoughts?myObject.fetch()will be started and IMMEDIATELY continue withconsole.log($scope.myData), although the fetch hasn't finished yet. Whatever you want to execute after fetch() returns, put it into a function and call it from within fetch().then()