Personal Site

Create now playing function

vielle.dev cc43861c c4b330a4

verified
+11
+11
src/components/playing/spotify.ts
··· 163 163 164 164 return res; 165 165 } 166 + 167 + export async function nowPlayingSongID() { 168 + const res = await getSpotifyApi("/me/player/currently-playing"); 169 + if (res instanceof Error) return res; 170 + 171 + // https://developer.spotify.com/documentation/web-api/reference/get-the-users-currently-playing-track 172 + const trackID = (res as { item: { id: string } | null }).item?.id; 173 + if (trackID === null) return null; 174 + 175 + return trackID; 176 + }