spotify / apps-tutorial

A Spotify App that contains working examples of the use of Spotify Apps API
https://developer.spotify.com/technologies/apps/
627 stars 146 forks source link

Cannot load artists from user library #38

Closed cvgellhorn closed 10 years ago

cvgellhorn commented 10 years ago

Hi guys,

I'm trying to load the artists rom the current user library:

require(['$api/library#Library'], function(Library) {
    Library.forCurrentUser().artists
        .snapshot()
        .done(function(snapshot) {
            var len = snapshot.length;
            for (var i = 0; i < len; i++) {
                var a = snapshot.get(i);
                console.log(a);
            }
        });
});

But I get this error on console:

TypeError: Cannot call method 'snapshot' of null 

I also tried this, to ensure that the artists property is available on the object:

require(['$api/library#Library'], function(Library) {
    Library.forCurrentUser().load("artists").done(function(library) {
        library.artists.snapshot().done(function(snapshot) {
             var len = snapshot.length;
             for (var i = 0; i < len; i++) {
                 var a = snapshot.get(i);
                 console.log(a);
             }
        });
    });
});

But the artists property is always null.

Is there any other way to get the artists from the current user library?

Thanks

JMPerez commented 10 years ago

Hi @cvgellhorn! That property is not exposed at the moment through the Spotify Apps API. If you check out the Documentation for Library, it states that This property is currently unsupported and should not be used.

At the moment users saves playlists to their library on the desktop client, and those are the ones you can have access to using the playlists property. If you are interested in the Artist, then you could traverse the tracks of those playlists and grab the artist from there.

cvgellhorn commented 10 years ago

Hi @JMPerez,

thanks for your quick reply.