From 6914cc0d2c6b572bfe2f1387994c6ac400f43b04 Mon Sep 17 00:00:00 2001 From: synan798 Date: Sun, 22 Dec 2024 17:20:22 +0100 Subject: [PATCH] removed getPlaylistItems --- composables/useSpotify.ts | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/composables/useSpotify.ts b/composables/useSpotify.ts index 902a13d..eea2d8e 100644 --- a/composables/useSpotify.ts +++ b/composables/useSpotify.ts @@ -95,7 +95,8 @@ export default function useSpotify(playlistId: string) { const data = await res.json(); for (const item of data.items) { - const itemCount = await getPlaylistItems(item.id); + const itemCount = item.tracks.total + console.log(itemCount) if (itemCount >= 8) { const exists = userPlaylists.value.some(playlist => playlist.id === item.id); if (!exists) { @@ -117,29 +118,6 @@ export default function useSpotify(playlistId: string) { } } - async function getPlaylistItems(playlistId: string): Promise { - try { - const res = await fetch(`https://api.spotify.com/v1/playlists/${ playlistId }/tracks`, { - method: 'GET', - headers: { - 'Authorization': `Bearer ${token.value}`, - }, - }); - - if (!res.ok) { - console.error(`Error: ${res.status} - ${res.statusText}`); - return 0; - } - - const data = await res.json(); - - return data.items.length; - } catch (error) { - console.error('Failed to get playlists:', error); - return 0; - } - } - async function getTrackCover(trackId: string): Promise { try { const res = await fetch(`https://api.spotify.com/v1/tracks/${trackId}`, { @@ -169,7 +147,6 @@ export default function useSpotify(playlistId: string) { followPlaylist, unfollowPlaylist, getUserPlaylists, - getPlaylistItems, getTrackCover }; }