spotify-web-api-node icon indicating copy to clipboard operation
spotify-web-api-node copied to clipboard

How do I get a playlist's name?

Open aryan-pirhashemi opened this issue 3 years ago • 1 comments

I need the name of the playlist, but for some reason, the data received object does not contain a name key with the name of the playlist. Any suggestions? (What I need is written with an arrow pointing towards it in the code snippet below.)

async function testMethod(offSet, musicList){ spotifyApi.getPlaylistTracks('7KRrhdcZBUSYGpsC7VytoW', {offset: offSet}) .then(function(data) { musicList = musicList.concat((data.body.items)) if(data.body.offset < (data.body.total - data.body.total % 100)){ testMethod(offSet + 100, musicList)
}else{ SpotifyPlaylist.setTrackList(musicList) SpotifyPlaylist.extractMetadata() console.log("\nFinished Retrieving the Songs in the Playlist: " + data.body.NAME) //<------- What I need }

}, function(err) {
    console.log('Something went wrong!', err);
})       

}

aryan-pirhashemi avatar Jun 27 '21 07:06 aryan-pirhashemi

You can get this from 'getPlaylist'


spotifyApi.getPlaylist('3M2kdDYpU39aJ2RVivaHaH')

        .then(data =>{

          console.log(data.body.name);

        })

        .catch(err => {});

Noelg14 avatar Jul 14 '21 07:07 Noelg14