mirror of
https://github.com/NoCrypt/migu.git
synced 2026-04-21 16:41:59 +00:00
fix: mal refresh
This commit is contained in:
parent
8f144f4352
commit
8f5ee3439f
2 changed files with 6 additions and 6 deletions
|
|
@ -119,16 +119,16 @@ class MALClient {
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (!res || res.status !== 404) throw e
|
if (!res || res.status !== 404) throw e
|
||||||
}
|
}
|
||||||
if (!res.ok && (res.status === 429 || res.status === 500)) {
|
if (!res?.ok && (res?.status === 429 || res?.status === 500)) {
|
||||||
throw res
|
throw res
|
||||||
}
|
}
|
||||||
let json = null
|
let json = null
|
||||||
try {
|
try {
|
||||||
json = await res.json()
|
json = await res.json()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (res.ok) printError(error)
|
if (res?.ok) printError(error)
|
||||||
}
|
}
|
||||||
if (!res.ok && res.status !== 404) {
|
if (!res?.ok && res?.status !== 404) {
|
||||||
if (json) {
|
if (json) {
|
||||||
for (const error of json?.errors || [json?.error] || []) {
|
for (const error of json?.errors || [json?.error] || []) {
|
||||||
let code = error
|
let code = error
|
||||||
|
|
@ -154,7 +154,7 @@ class MALClient {
|
||||||
code = 422
|
code = 422
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
code = res.status
|
code = res?.status
|
||||||
}
|
}
|
||||||
printError(code)
|
printError(code)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -148,8 +148,8 @@ export async function refreshMalToken (token) {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (!refresh || !(refresh.length > 0) || !response.ok) {
|
if (!refresh || !(refresh.length > 0) || !response?.ok) {
|
||||||
toast.error('Failed to re-authenticate with MyAnimeList. You will need to log in again.', { description: JSON.stringify(response.status) })
|
toast.error('Failed to re-authenticate with MyAnimeList. You will need to log in again.', { description: JSON.stringify(response?.status || response) })
|
||||||
debug(`Failed to refresh MyAnimeList User Token ${ !refresh || !(refresh.length > 0) ? 'as the refresh token could not be fetched!' : ': ' + JSON.stringify(response)}`)
|
debug(`Failed to refresh MyAnimeList User Token ${ !refresh || !(refresh.length > 0) ? 'as the refresh token could not be fetched!' : ': ' + JSON.stringify(response)}`)
|
||||||
if (malToken?.token === token) {
|
if (malToken?.token === token) {
|
||||||
swapProfiles(null)
|
swapProfiles(null)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue