read comment working

This commit is contained in:
isUnknown 2024-11-18 09:36:15 +01:00
parent 583daa1759
commit 39fc379541
12 changed files with 125 additions and 78 deletions

View file

@ -189,28 +189,25 @@ export const useApiStore = defineStore("api", () => {
}
}
async function readNotification(userUuid, group, notificationId) {
async function readNotification(notificationId) {
const headers = {
method: "POST",
body: JSON.stringify({
userUuid,
notificationId,
group,
}),
};
try {
const response = await fetch("/mark-as-read.json", headers);
const response = await fetch("/read-comment.json", headers);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const newNotifications = await response.json();
return newNotifications;
const data = await response.json();
if (data.error) {
throw new Error(data);
} else {
return data;
}
} catch (error) {
console.error(
"Une erreur s'est produite lors de la lecture de la notification n°",
notificationId,
error
);
throw error;
}
}