convert API call function to TS

This commit is contained in:
p2405951
2026-03-13 16:54:08 +01:00
parent e73d607ac3
commit 4325fe3dcb
21 changed files with 38 additions and 59 deletions
@@ -0,0 +1,27 @@
import getXSRFToken from "../getXSRF";
export default async function readNotifications() {
const csrfToken = await getXSRFToken();
try {
const res = await fetch(`${import.meta.env.VITE_API_URL}/api/users/notifications/read`, {
method: 'POST',
credentials: 'include',
headers: {
'Accept': 'application/json',
'X-XSRF-TOKEN': csrfToken,
'Content-Type': 'application/json',
},
});
if (!res.ok) {
throw new Error(`Erreur serveur : ${res.status}`);
}
return await res.json();
} catch (err) {
console.error('Erreur :', err);
return null;
}
}