DTL : optimization appointment request working

This commit is contained in:
isUnknown 2025-01-27 14:39:52 +01:00
parent 11657a5589
commit 54af78e32c
8 changed files with 132 additions and 25 deletions

View file

@ -75,24 +75,21 @@ export const useApiStore = defineStore("api", () => {
}
}
async function requestProjectCreation(data) {
async function post(data, route) {
const headers = {
method: "POST",
body: JSON.stringify(data),
};
try {
const response = await fetch("/request-project-creation.json", headers);
const response = await fetch(route, headers);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
console.log(data);
return data;
} catch (error) {
console.error(
"Une erreur s'est produite lors de l'ajout du commentaire :",
error
);
console.error("Une erreur s'est produite :", error);
throw error;
}
}
@ -249,6 +246,6 @@ export const useApiStore = defineStore("api", () => {
readNotification,
readAllNotifications,
validateBrief,
requestProjectCreation,
post,
};
});