JMPerez / spotify-web-api-js

A client-side JS wrapper for the Spotify Web API
https://jmperezperez.com/spotify-web-api-js/
MIT License
1.87k stars 265 forks source link

iPhone 4 Error when calling getUserPlaylists #16

Closed jacobgreen25 closed 9 years ago

jacobgreen25 commented 9 years ago

Hi,

I'm using the Spotify Web API to do the following function call.

spotifyApi.getUserPlaylists($scope.user.id) .then(function(data) { (err) { console.error(err); ga('send','event','error','spotifyLoadFailed'); });

And getting the following error. Error: 'null' is not an object (evaluating 'spotifyApi.getUserPlaylists($scope.user.id) .then')

It works on iPhone 5, 6 and all Android devices I've tested, yet, iPhone 4 says the data object returned is null.

jacobgreen25 commented 9 years ago

I was just told by a friend that iPhone 4 doesn't support promises and that's why the error is occurring.

JMPerez commented 9 years ago

@scotty914 If you still want to use Promises, have a look at the Usage section where there are links to some of these libraries. Otherwise you can always use callbacks. In your case, your code would become


spotifyApi.getUserPlaylists($scope.user.id, function(err, data) {
  if (err) {
    console.log(err);
    ga('send','event','error','spotifyLoadFailed');
  }
});