get database users

This commit is contained in:
T'JAMPENS QUENTIN p2406187 committed 2025-12-05 14:34:33 +01:00
1 parent 89d2af34b9
commit 79df0f5ab1
4 files changed
+121 -96

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
export default async function getUserById (id) {
try {
const res = await fetch(`http://${import.meta.env.VITE_API_URL}/api/users/${id}`, {
method: 'GET',
credentials: 'include',
headers: {
'Accept': 'application/json'
}
});
if (!res.ok) {
throw new Error(`Erreur serveur : ${res.status}`);
}
return await res.json();
} catch (err) {
console.error('Erreur :', err);
return null;
}
}