I think this is a bug with the API.
sp = getSpotifyAPI(1); models = sp.require('sp://import/scripts/api/models') models.library.playlists; > TypeError: Cannot read property 'length' of undefined try { models.library.playlists } catch(err) { console.log(err.stack) } > TypeError: Cannot read property 'length' of undefined at map (sp:216:20) at Library.<anonymous> (eval at evalModule (sp:55:46)) at unknown source at Object._evaluateOn (unknown source) at Object._evaluateAndWrap (unknown source) at Object.evaluate (unknown source)
Digging into the models.js file, we see that the library uses sp.core.library.getPlaylists () to get playlists that should return an array but return undefined:
sp.core.library.getPlaylists() > undefined sp.core.library.getPlaylists > function getPlaylists() { [native code] }
Since sp.core.library.getPlaylists is native code, I cannot go deeper into the rabbit hole to see what it does. Therefore, if spotify developers do not say that this is the desired behavior, my conclusion is that this is a mistake.
source share