24 lines
709 B
TypeScript
24 lines
709 B
TypeScript
// =============================================================================
|
|
// RBAC API HELPERS
|
|
// =============================================================================
|
|
|
|
export const API = '/api/sdk/v1/rbac'
|
|
|
|
export async function apiFetch<T>(path: string, opts?: RequestInit): Promise<T> {
|
|
const res = await fetch(`${API}/${path}`, {
|
|
headers: { 'Content-Type': 'application/json' },
|
|
...opts,
|
|
})
|
|
if (!res.ok) {
|
|
const err = await res.text()
|
|
throw new Error(`HTTP ${res.status}: ${err}`)
|
|
}
|
|
return res.json()
|
|
}
|
|
|
|
export function formatDate(iso: string): string {
|
|
return new Date(iso).toLocaleString('de-DE', {
|
|
day: '2-digit', month: '2-digit', year: 'numeric',
|
|
})
|
|
}
|