use fetchWrapper for getRoles.js

This commit is contained in:
T'JAMPENS QUENTIN p2406187
2026-01-28 15:27:41 +01:00
parent 659a6c1623
commit fc233d1498
2 changed files with 5 additions and 20 deletions
+3 -19
View File
@@ -1,21 +1,5 @@
import fetchWrapper from "./fetchWrapper.js";
export default async function getRoles() {
try {
const res = await fetch(`${import.meta.env.VITE_API_URL}/api/roles`, {
method: 'GET',
credentials: 'include',
headers: {
'Accept': 'application/json'
}
});
if (!res.ok) {
throw new Error(`Erreur serveur : ${res.status}`);
}
const data = await res.json();
return data;
} catch (err) {
console.error('Erreur :', err);
return null;
}
return fetchWrapper("/api/roles", null, "GET");
}