This commit is contained in:
2025-06-17 17:46:21 +01:00
parent efc4fdb4c0
commit 4a8395a307
38 changed files with 12370 additions and 1 deletions

18
src/utils/apiFetch.js Normal file
View File

@@ -0,0 +1,18 @@
// utils/apiFetch.js
import { getAuthHeader } from './apiAuthHeader';
export async function apiFetch(url, options = {}) {
const res = await fetch(url, {
...options,
headers: {
...getAuthHeader(),
...(options.headers || {}),
},
});
const json = await res.json();
if (!res.ok || !json.success) {
throw new Error(json.message || 'Erro na requisição');
}
return json.data;
}