Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
oldschoolshuffle
async function getSimpleAlbumTracks(albumId, albumName, albumUri){
//track_number is what track number a song is on the album
try {
const tracks = await spotifyApi.getAlbumTracks(albumId);
const simpleTracks = tracks.items.map((track) => {
const artist = track.artists[0];
return {
trackId: track.id,
trackName: track.name,
trackUri: track.uri,
trackNumber: track.track_number,
albumId: albumId,
albumName: albumName,
albumUri: albumUri,
artistId: artist.id,
artistName: artist.name,
artistUri: artist.uri,
}
})
return simpleTracks
}
catch(err) {
console.error('Error: getSimplePlaylistTracks in spotifyFunctions', err);
console.error(err.stack);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.