diff --git a/srcs/frontend/src/app.js b/srcs/frontend/src/app.js index 718acfa..fb4068a 100644 --- a/srcs/frontend/src/app.js +++ b/srcs/frontend/src/app.js @@ -1,14 +1,11 @@ import {Element, MenuElement} from "./element.js"; import {Grid} from "./grid.js"; import {fenetre, LoginWindow} from "./windows.js"; + function direBonjour() { alert("clicked !"); } - - - - const menuElement = new Element("menu"); const loginElement = new MenuElement("login"); const registeredElement = new MenuElement("registered"); diff --git a/srcs/frontend/src/windows.js b/srcs/frontend/src/windows.js index fc3024c..e03566b 100644 --- a/srcs/frontend/src/windows.js +++ b/srcs/frontend/src/windows.js @@ -86,11 +86,29 @@ export class LoginWindow extends fenetre { this.body.style.gap = "8px"; } - connexion(){ - console.log("methode connexion lancée"); + async connexion() { + const response = await fetch("/api/login", { + method: "POST", + headers: { + "Content-Type": "application/json" + }, + body: JSON.stringify({ + username: "nom", + password: "a" + }) + }); + + const data = await response.json(); + + if (response.ok) { + console.log("OK", data); + } else { + console.error("ERROR", data); + } } - inscription(){ + + async inscription(){ console.log("methode inscription lancée"); }