From 2174a08186250597d3e992ab051574997634bc8b Mon Sep 17 00:00:00 2001 From: skidoodle Date: Fri, 21 Oct 2022 17:55:12 +0200 Subject: [PATCH] fix api when song is not playing --- pages/api/spotify.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/api/spotify.ts b/pages/api/spotify.ts index 69510ea..54ff515 100644 --- a/pages/api/spotify.ts +++ b/pages/api/spotify.ts @@ -6,7 +6,7 @@ export default async function (req: NextApiRequest, res: NextApiResponse) { const spotify = new SpotifyService(CLIENT_ID!, CLIENT_SECRET!, REFRESH_TOKEN!) const song = await spotify.getCurrentSong() - if(!song.isPlaying) { + if(!song || !song.isPlaying ) { return res.status(200).json({ nowplaying: false, });