fix(web): admin bibliothèques — correctifs complémentaires client et AdminPage
- web: AdminPage, client API (+ tests), styles Refs: #15
This commit is contained in:
@ -56,15 +56,20 @@ function apiErrorMessage(detail: string, fallback: string): string {
|
||||
return fallback;
|
||||
}
|
||||
|
||||
function requestHeaders(options: RequestOptions): Headers {
|
||||
const headers = new Headers(options.headers);
|
||||
if (options.body !== undefined && !headers.has("Content-Type")) {
|
||||
headers.set("Content-Type", "application/json");
|
||||
}
|
||||
return headers;
|
||||
}
|
||||
|
||||
async function request<T>(path: string, options: RequestOptions = {}): Promise<T> {
|
||||
try {
|
||||
const response = await fetch(`${API_BASE}${path}`, {
|
||||
...options,
|
||||
credentials: "include",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
...options.headers
|
||||
}
|
||||
headers: requestHeaders(options)
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
|
||||
Reference in New Issue
Block a user