use fetchWrapper for getUser.js

This commit is contained in:
T'JAMPENS QUENTIN p2406187
2026-01-28 15:29:51 +01:00
parent fc233d1498
commit a0bba2deb4
2 changed files with 6 additions and 22 deletions
+3 -19
View File
@@ -1,21 +1,5 @@
import fetchWrapper from "./fetchWrapper.js";
export default async function getUser() {
try {
const res = await fetch(`${import.meta.env.VITE_API_URL}/api/users/me`, {
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/users/me", null, "GET");
}