Files
SAE-BUT2-frontend/src/utils/events/getEventById.js
T
2025-12-17 14:16:08 +01:00

23 lines
557 B
JavaScript

export default async function GetEventById(id) {
try {
const res = await fetch(`http://${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;
}
}