fix: add error handling to context doc/fact load functions
This commit is contained in:
parent
4096f890be
commit
6f9cfb8018
1 changed files with 10 additions and 4 deletions
|
|
@ -208,13 +208,19 @@ const error = ref<string | null>(null)
|
|||
const newFact = ref({ category: 'service', key: '', value: '' })
|
||||
|
||||
async function loadDocs() {
|
||||
const r = await fetch(`${BASE}/api/context/docs`)
|
||||
if (r.ok) docs.value = await r.json()
|
||||
try {
|
||||
const r = await fetch(`${BASE}/api/context/docs`)
|
||||
if (r.ok) docs.value = await r.json()
|
||||
else error.value = `Failed to load documents (${r.status})`
|
||||
} catch { error.value = 'Could not reach server' }
|
||||
}
|
||||
|
||||
async function loadFacts() {
|
||||
const r = await fetch(`${BASE}/api/context/facts`)
|
||||
if (r.ok) facts.value = await r.json()
|
||||
try {
|
||||
const r = await fetch(`${BASE}/api/context/facts`)
|
||||
if (r.ok) facts.value = await r.json()
|
||||
else error.value = `Failed to load facts (${r.status})`
|
||||
} catch { error.value = 'Could not reach server' }
|
||||
}
|
||||
|
||||
async function doDelete(id: string) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue