From 44605abc590a120c6028e45938e79804c19565fd Mon Sep 17 00:00:00 2001 From: maggick Date: Tue, 26 Mar 2024 12:09:59 +0100 Subject: [PATCH] Catch an error when Spotify API return a 500 --- src/script.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/script.ts b/src/script.ts index c6415f5..715bc86 100644 --- a/src/script.ts +++ b/src/script.ts @@ -144,9 +144,13 @@ async function fetchAlbums(code: string): Promise{ }); 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)