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,26 @@
import getXSRFToken from "../getXSRF.js";
export default async function deleteNotificationUser(notificationId:number) {
const csrfToken = await getXSRFToken();
try {
const res = await fetch(`${import.meta.env.VITE_API_URL}/api/users/delete/notification/${notificationId}`, {
method: 'DELETE',
credentials: 'include',
headers: {
'Accept': 'application/json',
'X-XSRF-TOKEN': csrfToken
}
});
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;
}
}