Add clearvisits API endpoint and implement DELETE method***
***Handle error when no id is found in DELETE method*** ***Update deleteData function in log page to use clearvisits API endpoint
This commit is contained in:
@@ -167,9 +167,23 @@
|
||||
}
|
||||
|
||||
function deleteData() {
|
||||
clearAdventures();
|
||||
adventures = getAdventures();
|
||||
showToast("deleted");
|
||||
fetch("/api/clearvisits", {
|
||||
method: "DELETE",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then((data) => {
|
||||
console.log("Success:", data);
|
||||
// remove adventure from array where id matches
|
||||
adventures = [];
|
||||
showToast("removed");
|
||||
visitCount.set(0);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Error:", error);
|
||||
});
|
||||
}
|
||||
|
||||
function removeAdventure(event: { detail: number }) {
|
||||
|
||||
Reference in New Issue
Block a user