implemented reset of config

This commit is contained in:
RaffaelW 2024-11-03 22:27:12 +01:00
parent 2ee16f6452
commit 8a3bd49686
5 changed files with 47 additions and 4 deletions

21
data/reset.js Normal file
View file

@ -0,0 +1,21 @@
import { writeDataToInput } from "/load-data.js";
const form = document.querySelector("form");
form.addEventListener("reset", async (event) => {
event.preventDefault();
try {
const res = await fetch("/reset", {
method: "POST",
});
if (!res.ok) {
throw new Error(`Response status: ${res.status}`);
}
const json = await res.json();
writeDataToInput(json);
} catch (error) {
console.error(error.message);
}
});