How to get all artists of a user (Spotify Api 1.x)? -
i'm trying list of artists user. easy in 0.x api, can't it.
require([ '$api/models', '$api/location#location', '$api/library#library', '$api/search#search', '$api/toplists#toplist', '$views/buttons', '$views/list#list', '$views/image#image' ], function(models, location, library, search, toplist, buttons, list, image) { var librarys = library.forcurrentuser(); console.log("library", librarys); librarys.load("artists").done( function(artists) { console.log(artists); artists.load('owner').done(function(snapshot) { console.log("snap",snapshot); }); }); }); i response of "library.forcurrentuser();" try next fails. there no error or something, either "librarys.load("artists")" nor "librarys.snapshot()" works.
by loading "artists" library, you're not getting artists in callback function, library has loaded artists. since never need have loaded, it's better performance if specify want have loaded. if wanted load tracks artists, use "artists", "tracks" load parameter.
if want see artists in current user's library, can so:
require(['$api/library#library'], function(library) { library.forcurrentuser().load("artists").done(function(library) { library.artists.snapshot().done(function(snapshot) { (var = 0; < snapshot.length; i++) { console.log(snapshot.get(i).name); } }); }); }); hope helps.
edit: working spotify apps api version 1.25.1.
Comments
Post a Comment