Created
September 12, 2018 18:49
-
-
Save gate5th/968b55664205e85a7ecadc8943e54836 to your computer and use it in GitHub Desktop.
oldschoolshuffle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function getSimplePlaylistTracks(playlistId){ | |
//track_number is what track number a song is on the album | |
try { | |
const tracks = await spotifyApi.getPlaylistTracks(playlistId); | |
//getPlaylistTracks has a bunch of meta data about the playlist we don't need | |
//once again items is the property we really want. It's an array of tracks | |
const simpleTracks = tracks.items.map((trackObject) => { | |
const track = trackObject.track; | |
const album = trackObject.track.album; | |
const artist = trackObject.track.artists[0] | |
return { | |
trackId: track.id, | |
trackName: track.name, | |
trackUri: track.uri, | |
trackNumber: track.track_number, | |
albumId: album.id, | |
albumName: album.name, | |
albumUri: album.uri, | |
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