Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | 45x 4x | import { getMyShows } from "utils/spotifyCalls";
export async function getAllMyShows(): Promise<SpotifyApi.UsersSavedShowsResponse | null> {
const limit = 50;
const showsData = await getMyShows(0);
Iif (!showsData) return null;
let restShowsData: SpotifyApi.UsersSavedShowsResponse | undefined;
const max = Math.ceil(showsData.total / limit);
Iif (max <= 1) {
return showsData;
}
for (let i = 1; i < max; i++) {
const resAlbumsData = await getMyShows(limit * i);
Iif (!resAlbumsData) return null;
if (restShowsData) {
restShowsData = {
...restShowsData,
items: [...restShowsData.items, ...resAlbumsData.items],
};
} else {
restShowsData = resAlbumsData;
}
}
Iif (!restShowsData) {
return showsData;
}
const allPlaylists = {
...showsData,
items: [...showsData.items, ...restShowsData.items],
};
return allPlaylists;
}
|