Админка рабочая

This commit is contained in:
Халимов Рустам
2026-03-31 15:43:24 +03:00
parent 8025340e45
commit 4faa7561a0
6 changed files with 583 additions and 516 deletions
@@ -15,8 +15,8 @@ export class HttpClient {
const isFormData = fetchOptions.body instanceof FormData;
const computedHeaders: Record<string, string> = {
...(this.token
? { Authorization: this.token.startsWith('Basic ') ? this.token : `Bearer ${this.token}` }
...(this.token
? { Authorization: this.token.startsWith('Basic ') ? this.token : `Bearer ${this.token}` }
: {}),
...(fetchOptions.headers as Record<string, string>),
};
@@ -47,7 +47,13 @@ export class HttpClient {
throw new Error(errorMessage);
}
const jsonData = await response.json();
// Handle empty responses (e.g., 200 OK with no body)
const text = await response.text();
if (!text) {
return undefined as T;
}
const jsonData = JSON.parse(text);
return deepNormalize(jsonData);
}
}