diff --git a/composables/useSpotify.ts b/composables/useSpotify.ts index 902a13d..e1cf86a 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,28 +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 { @@ -169,7 +148,6 @@ export default function useSpotify(playlistId: string) { followPlaylist, unfollowPlaylist, getUserPlaylists, - getPlaylistItems, getTrackCover }; }