// Kleiner Fetch-Wrapper — Cookies (Session) laufen automatisch mit (same-origin) async function api(path, options = {}) { const res = await fetch(path, { headers: { Accept: 'application/json' }, ...options }); if (!res.ok) { const error = new Error(`API ${res.status}`); error.status = res.status; throw error; } return res.json(); } export const apiGet = (path) => api(path); export const apiDelete = (path) => api(path, { method: 'DELETE' }); export const apiPut = (path, body) => api(path, { method: 'PUT', headers: { 'Content-Type': 'application/json', Accept: 'application/json' }, body: JSON.stringify(body), }); export const apiPost = (path, body = {}) => api(path, { method: 'POST', headers: { 'Content-Type': 'application/json', Accept: 'application/json' }, body: JSON.stringify(body), });