From a function, I'd like to return a collection of soundcloud sounds using the SoundCloud javascript SDK. However, because soundcloud is using asynchronous requests, the is not possible:
function getFavorites() {
var tracks = [];
SC.get('/users/1234', function(data) {
$.each(data, function (i, obj) {
tracks.push(obj);
});
return tracks;
});
}
How can I return a value from an asychronous request?