Fix crash with wrong spotify username

This commit is contained in:
RemixDev 2022-05-28 15:49:26 +02:00
parent f279ed43b5
commit 516eb2557f
1 changed files with 7 additions and 1 deletions

View File

@ -10,7 +10,13 @@ const handler: ApiHandler['handler'] = async (req, res) => {
const sp = deemix.plugins.spotify.sp const sp = deemix.plugins.spotify.sp
const username = req.query.spotifyUser const username = req.query.spotifyUser
data = [] data = []
let playlists = await sp.getUserPlaylists(username) let playlists
try {
playlists = await sp.getUserPlaylists(username)
} catch (e) {
res.send({ error: 'wrongSpotifyUsername', username })
return
}
playlists = playlists.body playlists = playlists.body
let playlistList = playlists.items let playlistList = playlists.items
while (playlists.next) { while (playlists.next) {