spotify-web-api-node
spotify-web-api-node copied to clipboard
How do I get a playlist's name?
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);
})
}
You can get this from 'getPlaylist'
spotifyApi.getPlaylist('3M2kdDYpU39aJ2RVivaHaH')
.then(data =>{
console.log(data.body.name);
})
.catch(err => {});