implemented loading animation during requests

This commit is contained in:
RaffaelW 2024-11-05 09:11:36 +01:00
parent b8b87db0f2
commit f0204c2477
6 changed files with 178 additions and 53 deletions

View file

@ -1,4 +1,4 @@
import { writeDataToInput } from "/load-data.js";
import { updateConfig } from "/submit.js";
const form = document.querySelector("form");
@ -9,22 +9,8 @@ form.addEventListener("reset", async (event) => {
"Sicher, dass du alle Einstellungen zurücksetzen möchtest?"
);
if (ok) {
reset();
}
});
async function reset() {
try {
const res = await fetch("/config", {
updateConfig({
method: "DELETE",
});
if (!res.ok) {
throw new Error(`Response status: ${res.status}`);
}
const json = await res.json();
writeDataToInput(json);
} catch (error) {
console.error(error.message);
}
}
});