Files
SAE-BUT2-frontend/src/utils/events/getEventById.js
T

23 lines
550 B
JavaScript

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;
}
}