Updated fetch to actually retry on 401 with new token

This commit is contained in:
lucast committed 2026-02-24 19:27:14 +01:00
1 parent 581c522b00
commit 464bbaef9e
3 files changed
+14 -15

No files matched your search

+3 -3
View File
@@ -62,13 +62,13 @@ export const cfetch = async (
let response
try {
response = await axios(url, config)
} catch {
if (response?.status == 401) {
} catch (error: any) {
if (error.response?.status == 401) {
if (!config.headers) config.headers = {}
config.headers.Authorization = `Bearer ${await refreshSessionToken()}`
response = await axios(url, config)
}
} else throw error
}
if (!response) throw new Error("Something went wrong. Please try again")