1
votes

I'm trying to get the list of albums for an artist in an app using the Spotify Apps API. The documentation says that there is a getAlbums method in the Artist class which will get the albums for the artist:

http://developer.spotify.com/download/spotify-apps-api/reference/8a6410b5e6.html

However, when I use this in my code I get the error:

Uncaught TypeError: Object artist name has no method 'getAlbums'"

Here is the code I am using:

console.log(artist);
var a = artist.getAlbums(function(albums) {
    console.log(albums);
});

Checking in the Console, the variable artist is definitely an Artist class. Am I missing something, or is this method not yet implemented (or removed)? I believe I am using the latest preview version (0.8.2.572.geb65f9ac).

2

2 Answers

2
votes

This was mistakenly removed from a recent update. It's in our log to get it put back in again as soon as we reasonably can.

0
votes

Use models.Search:

var sp = getSpotifyApi(1);
var models = sp.require('sp://import/scripts/api/models');

var search = new models.Search('Rihanna');

search.observe(models.EVENT.CHANGE, function() {
    var results = search.albums;
    console.log(results);
});

Here is more documentation about models.Search: https://developer.spotify.com/technologies/apps/docs/beta/833e3a06d6.html