angular-tasty-resource
angular-tasty-resource copied to clipboard
The .query() just returns an empty array
The results [] array in queryURL that gets returned doesnt sync up w/ the values pushed onto it in the promise.then function
@gsterjov, any feedback?
Sorry, it has been a while. I'm not sure I know what you mean. Would you mind providing an example.
I figured it out... When I tried:
$scope.users = User.query();
console.log($scope.users);
An empty array was printed to the console. I realized that (after looking through your code) an empty array was printed b/c the ajax query hadn't had a chance to fetch the request.
The following worked for me:
$scope.users = User.query(function(response){
$scope.users = response.data.objects;
console.log($scope.users)
});
I love this module btw.. You've saved me a lot of time re-writing repetitive code. Can you mention this in documentation so that noobs like myself won't get confused about why the data isn't immediately available after .query(), .get(), etc. function calls?
Found this answer after 3 hours of debugging (I don't know why I did't google it right away). Thanks!