From bdb85e6570f54e38dc16a737b3e9137efde03456 Mon Sep 17 00:00:00 2001 From: Arthur DANJOU Date: Tue, 18 Jan 2022 18:28:42 +0100 Subject: [PATCH] Fix 401 error --- app/Utils/SongUtils.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/app/Utils/SongUtils.ts b/app/Utils/SongUtils.ts index 7ad2366..2a32d21 100644 --- a/app/Utils/SongUtils.ts +++ b/app/Utils/SongUtils.ts @@ -82,22 +82,19 @@ export async function regenerateTokens(): Promise { } async function RequestWrapper(url: string): Promise | undefined> { - let request const options: AxiosRequestConfig = { headers: { Authorization: `Bearer ${(await getSpotifyAccount()).access_token}`, }, } + try { - request = await axios.get(url, options) + return await axios.get(url, options) } catch (error) { await regenerateTokens() - request = await axios.get(url, options) + return RequestWrapper(url) } - - if (request.status === 200) - return request } export async function getCurrentPlayingFromCache(): Promise {