If I am getting data from a json api (playlists.json), and the playlist object has a user_id
data field, how can I get a specific playlist with user_id == 1
?
I tried doing:
var playlists = Restangular.all('playlists');
playlists.getList().then(function(data) {
for(var i = 0; i < data.length; i++) {
var obj = data[i];
if(obj.user_id == 1) {
$scope.playlist = obj;
}
}
});
But I would rather not retrieve all the playlists and loop through all of them as it seems very inefficient.
Thanks in advance!