- [ ] Create backend route: router.get("/spotify/track", authenticateJWT, async (req, res) => { ... }); Inside the controller: - [ ] Extract user’s Spotify access token (from req.user or req.session) - [ ] Try calling: GET https://api.spotify.com/v1/me/player/currently-playing - [ ] If 204 or empty, fallback to: GET https://api.spotify.com/v1/me/player/recently-played?limit=1 - [ ] Extract metadata from either source: - spotifyTrackId - title - artist (joined string) - albumArt (track.album.images[0].url) - preview_url - [ ] Return cleaned data to frontend: { "spotifyTrackId": "...", "title": "...", "artist": "...", "albumArt": "...", "preview_url": "..." }
router.get("/spotify/track", authenticateJWT, async (req, res) => { ... });
Inside the controller:
Extract user’s Spotify access token (from req.user or req.session)
Try calling:
GET https://api.spotify.com/v1/me/player/currently-playing
If 204 or empty, fallback to:
GET https://api.spotify.com/v1/me/player/recently-played?limit=1
Extract metadata from either source:
spotifyTrackId
title
artist (joined string)
albumArt (track.album.images[0].url)
preview_url
Return cleaned data to frontend:
{
"spotifyTrackId": "...",
"title": "...",
"artist": "...",
"albumArt": "...",
"preview_url": "..."
}