use fetchWrapper for getEventById.js

This commit is contained in:
T'JAMPENS QUENTIN p2406187
2026-01-28 15:19:44 +01:00
parent e9c8b7cda8
commit 4f184dd7c5
3 changed files with 7 additions and 25 deletions
+4 -22
View File
@@ -1,23 +1,5 @@
import fetchWrapper from "../fetchWrapper.js";
export default async function GetEventById(id) {
try {
const res = await fetch(`${import.meta.env.VITE_API_URL}/api/events/${id}`, {
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/events/${id}`, null, "GET");
}