vor subdomain UX anpassung

This commit is contained in:
ecki
2026-04-06 18:21:01 +02:00
parent e4e42b0472
commit 39f5f262fe
7 changed files with 260 additions and 138 deletions
+30 -4
View File
@@ -1,6 +1,7 @@
const API = "/resman/api"
async function api(url, options = {}) {
async function api(url, options = {}, config = {}) {
const showToast = config.showError !== false
const res = await fetch(url, options)
let data
@@ -14,10 +15,35 @@ async function api(url, options = {}) {
if (!res.ok) {
const msg = data.error || "Unbekannter Fehler"
showError(msg)
if (showToast) {
showError(msg)
}
throw new Error(msg)
const error = new Error(msg)
error.status = res.status
error.data = data
throw error
}
return data
}
}
window.runAction = async function(action, onSuccess) {
try {
await action()
if (onSuccess) {
await onSuccess()
}
return true
} catch (error) {
if (error && error.silent) {
return false
}
console.error(error)
return false
}
}