diff options
author | LarsVomMars | 2020-07-30 20:16:54 +0200 |
---|---|---|
committer | LarsVomMars | 2020-07-30 20:16:54 +0200 |
commit | f02c4054984fb8c12bfa4af9560a5b2be38810c0 (patch) | |
tree | d4519a92b739640e061847831d221e3e2488a83c /src/public/js/login.js | |
parent | 86c68c3648c94ca9f66f3eb408973368bed28681 (diff) |
Added views and server setup
Diffstat (limited to 'src/public/js/login.js')
-rw-r--r-- | src/public/js/login.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/public/js/login.js b/src/public/js/login.js new file mode 100644 index 0000000..681b02f --- /dev/null +++ b/src/public/js/login.js @@ -0,0 +1,18 @@ +const form = document.getElementById("login-form"); + +form.addEventListener('submit', async e => { + e.preventDefault(); + const username = document.getElementById("username").value; + const password = document.getElementById("password").value; + + const body = JSON.stringify({username, password}); + + const resp = await fetch("/user/login", { + method: "POST", + headers: {'Content-Type': 'application/json'}, + body, + }); + const res = await resp.json(); + if (res.success) location.replace("/"); + else alert("ASJHDOAISJDLKAJSD"); +})
\ No newline at end of file |