add read notifications route and update notifications behavior

This commit is contained in:
2026-01-08 15:00:43 +01:00
parent 21259f2838
commit 42748ad722
6 changed files with 301 additions and 11 deletions
@@ -0,0 +1,27 @@
import getXSRFToken from "../getXSRF.js";
export default async function readNotifications() {
const csrfToken = await getXSRFToken();
try {
const res = await fetch(`http://${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;
}
}