beginn frontend modularisierung

This commit is contained in:
ecki
2026-03-10 17:06:16 +01:00
parent 44623422bc
commit 6912e1cc39
4 changed files with 43 additions and 29 deletions
+11 -10
View File
@@ -1,22 +1,23 @@
const API = "/resman/api";
async function api(url, options = {}) {
const API="/resman/api";
async function api(url, options={}){
const res = await fetch(url, options);
if (!res.ok) {
if(!res.ok){
let msg = "API error";
let msg="API error";
try {
const err = await res.json();
msg = err.error || msg;
} catch(e){}
alert("Fehler: " + msg);
try{
const err=await res.json();
msg=err.error || msg;
}catch(e){}
alert("Fehler: "+msg);
throw new Error(msg);
}
return res.json();
}