Skip to content

Commit

Permalink
Fix liked tracks endpoint
Browse files Browse the repository at this point in the history
v1/users/[id]/tracks seems to have been removed in favor of v1/me/tracks

https://developer.spotify.com/documentation/web-api/reference/get-users-saved-tracks
  • Loading branch information
watsonbox committed Sep 20, 2024
1 parent bbe2841 commit b2cbef3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/components/PlaylistTable.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ describe("single playlist exporting", () => {
expect(handlerCalled.mock.calls).toEqual([ // Ensure API call order and no duplicates
['https://api.spotify.com/v1/me'],
['https://api.spotify.com/v1/users/watsonbox/playlists?offset=0&limit=20'],
['https://api.spotify.com/v1/users/watsonbox/tracks'],
['https://api.spotify.com/v1/me/tracks'],
['https://api.spotify.com/v1/me/tracks?offset=0&limit=50']
])
})
Expand Down Expand Up @@ -163,7 +163,7 @@ describe("single playlist exporting", () => {
expect(handlerCalled.mock.calls).toEqual([ // Ensure API call order and no duplicates
['https://api.spotify.com/v1/me'],
['https://api.spotify.com/v1/users/watsonbox/playlists?offset=0&limit=20'],
['https://api.spotify.com/v1/users/watsonbox/tracks'],
['https://api.spotify.com/v1/me/tracks'],
['https://api.spotify.com/v1/me/tracks?offset=0&limit=50'],
['https://api.spotify.com/v1/artists?ids=4TXdHyuAOl3rAOFmZ6MeKz']
])
Expand Down Expand Up @@ -216,7 +216,7 @@ describe("single playlist exporting", () => {
expect(handlerCalled.mock.calls).toEqual([ // Ensure API call order and no duplicates
['https://api.spotify.com/v1/me'],
['https://api.spotify.com/v1/users/watsonbox/playlists?offset=0&limit=20'],
['https://api.spotify.com/v1/users/watsonbox/tracks'],
['https://api.spotify.com/v1/me/tracks'],
['https://api.spotify.com/v1/me/tracks?offset=0&limit=50'],
['https://api.spotify.com/v1/audio-features?ids=1GrLfs4TEvAZ86HVzXHchS']
])
Expand Down Expand Up @@ -269,7 +269,7 @@ describe("single playlist exporting", () => {
expect(handlerCalled.mock.calls).toEqual([ // Ensure API call order and no duplicates
['https://api.spotify.com/v1/me'],
['https://api.spotify.com/v1/users/watsonbox/playlists?offset=0&limit=20'],
['https://api.spotify.com/v1/users/watsonbox/tracks'],
['https://api.spotify.com/v1/me/tracks'],
['https://api.spotify.com/v1/me/tracks?offset=0&limit=50'],
['https://api.spotify.com/v1/albums?ids=4iwv7b8gDPKztLkKCbWyhi']
])
Expand Down Expand Up @@ -324,7 +324,7 @@ describe("single playlist exporting", () => {
expect(handlerCalled.mock.calls).toEqual([ // Ensure API call order and no duplicates
['https://api.spotify.com/v1/me'],
['https://api.spotify.com/v1/users/watsonbox/playlists?offset=0&limit=20'],
['https://api.spotify.com/v1/users/watsonbox/tracks'],
['https://api.spotify.com/v1/me/tracks'],
['https://api.spotify.com/v1/me/tracks?offset=0&limit=50'],
['https://api.spotify.com/v1/albums?ids=4iwv7b8gDPKztLkKCbWyhi']
])
Expand Down
2 changes: 1 addition & 1 deletion src/components/data/PlaylistsData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class PlaylistsData {
return
}

const likedTracksUrl = `https://api.spotify.com/v1/users/${this.userId}/tracks`
const likedTracksUrl = `https://api.spotify.com/v1/me/tracks`
const likedTracksResponse = await apiCall(likedTracksUrl, this.accessToken)
const likedTracksData = likedTracksResponse.data

Expand Down
2 changes: 1 addition & 1 deletion src/mocks/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const handlers = [
))
}),

rest.get('https://api.spotify.com/v1/users/watsonbox/tracks', (req, res, ctx) => {
rest.get('https://api.spotify.com/v1/me/tracks', (req, res, ctx) => {
handlerCalled(req.url.toString())

if (req.headers.get("Authorization") !== "Bearer TEST_ACCESS_TOKEN") {
Expand Down

0 comments on commit b2cbef3

Please sign in to comment.