Админка рабочая
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user