fix(auth): inventoryApi - use apiFetch with /backend prefix and Authorization header
This commit is contained in:
@@ -1,14 +1,13 @@
|
||||
import { apiFetch } from './api';
|
||||
import type { EntityResponse, InventoryTreeNode, ListResponse, NodeContext, Relation } from '../types/inventory';
|
||||
|
||||
async function handleResponse<T>(response: Response): Promise<T> {
|
||||
if (!response.ok) {
|
||||
throw new Error(`API error: ${response.status}`);
|
||||
}
|
||||
if (!response.ok) throw new Error(`API error: ${response.status}`);
|
||||
return response.json() as Promise<T>;
|
||||
}
|
||||
|
||||
async function fetchJson<T>(url: string): Promise<T> {
|
||||
const response = await fetch(url, { cache: 'no-store' });
|
||||
async function fetchJson<T>(path: string): Promise<T> {
|
||||
const response = await apiFetch(path, { cache: 'no-store' });
|
||||
return handleResponse<T>(response);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user