fix(auth): inventoryApi - use apiFetch with /backend prefix and Authorization header

This commit is contained in:
2026-08-06 16:39:57 +00:00
parent 1e0956dcc8
commit 0d9468eedf
+4 -5
View File
@@ -1,14 +1,13 @@
import { apiFetch } from './api';
import type { EntityResponse, InventoryTreeNode, ListResponse, NodeContext, Relation } from '../types/inventory'; import type { EntityResponse, InventoryTreeNode, ListResponse, NodeContext, Relation } from '../types/inventory';
async function handleResponse<T>(response: Response): Promise<T> { async function handleResponse<T>(response: Response): Promise<T> {
if (!response.ok) { if (!response.ok) throw new Error(`API error: ${response.status}`);
throw new Error(`API error: ${response.status}`);
}
return response.json() as Promise<T>; return response.json() as Promise<T>;
} }
async function fetchJson<T>(url: string): Promise<T> { async function fetchJson<T>(path: string): Promise<T> {
const response = await fetch(url, { cache: 'no-store' }); const response = await apiFetch(path, { cache: 'no-store' });
return handleResponse<T>(response); return handleResponse<T>(response);
} }