Skip to content

Commit 672b3fd

Browse files
committed
Fixing more response formats
1 parent 2f11e44 commit 672b3fd

File tree

8 files changed

+15
-12
lines changed

8 files changed

+15
-12
lines changed

components/spotify/actions/add-items-to-playlist/add-items-to-playlist.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export default {
4444
uris: this.spotify.sanitizedArray(uris),
4545
};
4646

47-
const resp = await this.spotify._makeRequest({
47+
const { data: resp } = await this.spotify._makeRequest({
4848
$,
4949
method: "POST",
5050
url: `/playlists/${playlistId.value ?? playlistId}/tracks`,

components/spotify/actions/create-playlist/create-playlist.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export default {
5252
collaborative: isCollaborative,
5353
};
5454

55-
const resp = await this.spotify._makeRequest({
55+
const { data: resp } = await this.spotify._makeRequest({
5656
$,
5757
method: "POST",
5858
url: `/users/${this.spotify.$auth.oauth_uid}/playlists`,

components/spotify/actions/get-album-tracks/get-album-tracks.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ export default {
5050
let total = 0;
5151

5252
do {
53-
const { items } = await this.spotify._makeRequest({
53+
const { data } = await this.spotify._makeRequest({
5454
$,
5555
url: `/albums/${this.albumId}/tracks`,
5656
params,
5757
});
58-
tracks.push(...items);
59-
total = items.length;
58+
tracks.push(...data.items);
59+
total = data.items.length;
6060
params.offset += params.limit;
6161
} while (total === params.limit);
6262

components/spotify/actions/get-audio-features-for-a-track/get-audio-features-for-a-track.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ export default {
2222
},
2323
async run({ $ }) {
2424
const { trackId } = this;
25-
const resp = await this.spotify._makeRequest({
25+
const { data } = await this.spotify._makeRequest({
2626
$,
2727
url: `/audio-features/${trackId.value ?? trackId}`,
2828
});
2929

3030
$.export("$summary", `Successfully fetched audio info for the track, "${trackId.label ?? trackId}"`);
3131

32-
return resp;
32+
return data;
3333
},
3434
};

components/spotify/actions/get-currently-playing-track/get-currently-playing-track.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export default {
2727
const { market } = this;
2828

2929
try {
30-
const res = await this.spotify._makeRequest({
30+
const { data: res } = await this.spotify._makeRequest({
3131
$,
3232
url: "/me/player/currently-playing",
3333
params: {

components/spotify/actions/remove-items-from-playlist/remove-items-from-playlist.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export default {
5151
snapshot_id: snapshotId,
5252
};
5353

54-
const resp = await this.spotify._makeRequest({
54+
const { data: resp } = await this.spotify._makeRequest({
5555
$,
5656
method: "DELETE",
5757
url: `/playlists/${playlistId.value ?? playlistId}/tracks`,

components/spotify/actions/save-track/save-track.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default {
2525
},
2626
async run({ $ }) {
2727
const ids = this.spotify.sanitizedArray(this.trackIds);
28-
const res = await this.spotify._makeRequest({
28+
const { data: res } = await this.spotify._makeRequest({
2929
$,
3030
method: "PUT",
3131
url: "/me/tracks",

components/spotify/spotify.app.mjs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,9 @@ export default {
278278
} catch (err) {
279279
if (err?.status !== 429 || retries <= 3) {
280280
$?.export?.("response", err);
281-
throw new Error("Error response");
281+
throw new Error("Error response exported in the \"response\" object");
282282
}
283+
283284
// if rate limit is exceeded, Retry-After will contain the # of seconds
284285
// to wait before retrying
285286
const delay = err?.headers?.["Retry-After"]
@@ -330,7 +331,9 @@ export default {
330331
return item.name;
331332
}
332333
},
333-
async getPlaylist(playlistId, args) {
334+
async getPlaylist({
335+
playlistId, ...args
336+
}) {
334337
const { data } = await this._makeRequest({
335338
url: `/playlists/${playlistId}`,
336339
...args,

0 commit comments

Comments
 (0)