Consistently use apiJson for fetches, with timeout and proper error handling (less code duplication).

This commit is contained in:
Leo Vasanko
2025-12-03 13:00:24 -06:00
parent ceb99de738
commit 4306323c44
9 changed files with 173 additions and 194 deletions
+2 -4
View File
@@ -101,7 +101,7 @@ import { useAuthStore } from '@/stores/auth'
import { adminUiPath, makeUiHref } from '@/utils/settings'
import passkey from '@/utils/passkey'
import { goBack } from '@/utils/helpers'
import { apiFetch } from '@/utils/api'
import { apiJson } from '@/utils/api'
const authStore = useAuthStore()
const updateInterval = ref(null)
@@ -174,9 +174,7 @@ const saveName = async () => {
if (!name) { authStore.showMessage('Name cannot be empty', 'error'); return }
try {
saving.value = true
const res = await apiFetch('/auth/api/user/display-name', { method: 'PUT', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ display_name: name }) })
const data = await res.json()
if (!res.ok || data.detail) throw new Error(data.detail || 'Update failed')
await apiJson('/auth/api/user/display-name', { method: 'PUT', body: { display_name: name } })
showNameDialog.value = false
await authStore.loadUserInfo()
authStore.showMessage('Name updated successfully!', 'success', 3000)