mirror of
https://github.com/ArthurDanjou/artdanj-api.git
synced 2026-01-14 12:14:33 +01:00
Fix 401 error
This commit is contained in:
@@ -82,22 +82,19 @@ export async function regenerateTokens(): Promise<void> {
|
||||
}
|
||||
|
||||
async function RequestWrapper<T = never>(url: string): Promise<AxiosResponse<T> | undefined> {
|
||||
let request
|
||||
const options: AxiosRequestConfig = {
|
||||
headers: {
|
||||
Authorization: `Bearer ${(await getSpotifyAccount()).access_token}`,
|
||||
},
|
||||
}
|
||||
|
||||
try {
|
||||
request = await axios.get<T>(url, options)
|
||||
return await axios.get<T>(url, options)
|
||||
}
|
||||
catch (error) {
|
||||
await regenerateTokens()
|
||||
request = await axios.get<T>(url, options)
|
||||
return RequestWrapper<T>(url)
|
||||
}
|
||||
|
||||
if (request.status === 200)
|
||||
return request
|
||||
}
|
||||
|
||||
export async function getCurrentPlayingFromCache(): Promise<InternalPlayerResponse> {
|
||||
|
||||
Reference in New Issue
Block a user