How can I efficiently retrieve a specific playlist with user_id == 1
from a json api (playlists.json) without having to loop through all playlists?
This is what I have tried so far:
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;
}
}
});
I believe there might be a more efficient way to achieve this without retrieving and looping through all the playlists. Any suggestions would be greatly appreciated!