Function: fetchWithAuth()¶
fetchWithAuth(
endpoint,options?):Promise\<Response>
Defined in: lib/api.ts:125
Fetches from authenticated API endpoint with Keycloak JWT.
Automatically: - Injects Keycloak JWT in Authorization header - Refreshes token if expiring within 30 seconds - Redirects to login if token refresh fails - Throws error with API message on 4xx/5xx status
Parameters¶
| Parameter | Type | Description |
|---|---|---|
endpoint |
string |
API endpoint path (e.g., "/zones", "zones") |
options? |
RequestInit |
Fetch options (method, body, headers, etc.) |
Returns¶
Promise\<Response>
HTTP response object
Throws¶
If authentication fails or API returns error status