123456789101112131415161718192021222324 |
- export function switchView(idSelector) {
- const button = document.querySelector(idSelector);
- if (!button) {
- return
- }
- button.addEventListener("click", (event) => {
- event.preventDefault();
- change();
- })
-
- function change() {
- const fetchPromise = fetch("/changeview");
- fetchPromise
- .then((response) => {
- if (!response.ok) {
- throw new Error(`Erreur Http : ${response.status}`);
- }
- return response.json();
- })
- .then((json) => {
- window.location.reload();
- })
- }
- }
|