Question

I'm building an app which requests data for several albums and playlists when it first loads.

For each of these I am calling either

models.Album.fromURI(uri, function(album){});

or

models.Playlist.fromURI(uri, function(playlist){});

For the majority of the time these work fine and I can get info from the album or playlist from within the callback function, however, occasionally (5% of the time) the callback function is never called and I'm left with an incomplete data set for my app to display.

I'm wondering if anyone else has encountered similar problems or has any insight into what might be causing it (API bugs, request rate limiting, etc)

Was it helpful?

Solution

Unfortunately, the Spotify Apps API 0.X lacked an error callback function that could be called when something went wrong when calling models.Album.fromURI or models.Playlist.fromURI.

This has been greatly improved in the Spotify Apps API 1.x through the use of Promises:

models.Track.fromURI('spotify:track:6a41rCqZhb2W6rpMolDR08').load('name')
    .done(function(track) { console.log(track.name); })
    .fail(function(track, error) { console.log(error.message); });
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top