Skip to content

Commit 3395989

Browse files
committed
Address deprecated /tracks endpoint
These changes correspond with the recommended `GET /playlists/{playlist_id}/items` call for fetching tracks. https://developer.spotify.com/documentation/web-api/reference/get-playlists-tracks states that `GET /playlists/{playlist_id}/tracks` is deprecated.
1 parent 47bd694 commit 3395989

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/services/trackService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ export const getPlaylistTracks = async (
77
accessToken: string,
88
signal?: AbortSignal,
99
): Promise<SpotifyTrack[]> => {
10-
const url = `${SPOTIFY_API_BASE_URL}/playlists/${playlist_id}/tracks`;
10+
const url = `${SPOTIFY_API_BASE_URL}/playlists/${playlist_id}/items`;
1111
const data: SpotifyTrackResponse = await spotifyFetch(
1212
url,
1313
accessToken,
1414
signal,
1515
);
16-
return data.items.map(item => item.track);
16+
return data.items.map(i => i.item);
1717
};

src/types/SpotifyPlaylist.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export interface SpotifyPlaylistResponse {
77

88
export interface SpotifyTrackResponse {
99
items: {
10-
track: SpotifyTrack;
10+
item: SpotifyTrack;
1111
}[];
1212
total: number;
1313
}

0 commit comments

Comments
 (0)