Skip to content

Instantly share code, notes, and snippets.

@gate5th
Created September 12, 2018 18:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gate5th/8dad67e4831c103784190cf0aee6f3f1 to your computer and use it in GitHub Desktop.
Save gate5th/8dad67e4831c103784190cf0aee6f3f1 to your computer and use it in GitHub Desktop.
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