Skip to content

Commit

Permalink
Catch an error when Spotify API return a 500
Browse files Browse the repository at this point in the history
  • Loading branch information
maggick committed Mar 26, 2024
1 parent c17778e commit 44605ab
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,13 @@ async function fetchAlbums(code: string): Promise<Album[]>{
});

albumsList = await result.json();
albumsList.items.forEach(item =>{
albums.push(item.album);
})
try{
albumsList.items.forEach(item =>{
albums.push(item.album);
})
} catch (TypeError){
console.log('Spotify API server error.');
}
offset +=50;
} while (albumsList.next != null)

Expand Down

0 comments on commit 44605ab

Please sign in to comment.