From 950a6909f214448c054693f4c8f74e00c50d7dfd Mon Sep 17 00:00:00 2001 From: Leopoldadmin Date: Thu, 4 Jun 2026 00:06:29 +0000 Subject: [PATCH] Upload app/webui/js/api.js --- app/webui/js/api.js | 158 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 158 insertions(+) create mode 100644 app/webui/js/api.js 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