reworked the chat layout and fixed a rate limiting mistake
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { initAuth } from '../stores/auth.ts'
|
||||
import { initAuth, logout } from '../stores/auth.ts'
|
||||
import { API } from '../main.ts'
|
||||
import router from '../router'
|
||||
|
||||
export async function apiFetch<T>(
|
||||
path: string,
|
||||
@@ -16,6 +17,12 @@ export async function apiFetch<T>(
|
||||
},
|
||||
})
|
||||
|
||||
if (res.status === 401) {
|
||||
await logout()
|
||||
router.push('/login')
|
||||
throw new Error("Session expired")
|
||||
}
|
||||
|
||||
if (!res.ok) {
|
||||
const text = await res.text()
|
||||
throw new Error(text || res.statusText)
|
||||
@@ -23,4 +30,3 @@ export async function apiFetch<T>(
|
||||
|
||||
return res.json()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user