fix(erp): enable erp pages and menu items
This commit is contained in:
@@ -43,13 +43,24 @@ export async function apiRequest<T = any>(
|
||||
},
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
// Handle empty responses
|
||||
const text = await response.text();
|
||||
let data: any = {};
|
||||
|
||||
if (text) {
|
||||
try {
|
||||
data = JSON.parse(text);
|
||||
} catch (e) {
|
||||
// If not JSON but has text, might be an error or plain text
|
||||
data = { message: text };
|
||||
}
|
||||
}
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(data.message || `Erro ${response.status}`);
|
||||
}
|
||||
|
||||
return data;
|
||||
return data as T;
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
throw error;
|
||||
|
||||
Reference in New Issue
Block a user