diff --git a/app/webui/js/api.js b/app/webui/js/api.js new file mode 100644 index 0000000..410f962 --- /dev/null +++ b/app/webui/js/api.js @@ -0,0 +1,158 @@ +/** + * CRM Frontend API-Wrapper + * + * Lightweight fetch() wrapper with: + * - Automatic JWT injection (Authorization: Bearer from localStorage) + * - 401 handling: clears token + redirects to /index.html + * - JSON-only requests (FormData→x-www-form-urlencoded via postForm) + * - ApiError class with status and parsed body for granular error handling + * + * All pages import this via