Create
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
var form = null
|
||||
|
||||
async function submit(e) {
|
||||
e.preventDefault()
|
||||
|
||||
const formData = new FormData(form)
|
||||
|
||||
try {
|
||||
const response = await fetch("https://example.org/post", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
})
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
window.sessionStorage.setItem("user", data.user)
|
||||
window.sessionStorage.setItem("session", data.session)
|
||||
|
||||
window.location.assign("/");
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
window.onload = () => {
|
||||
form = document.getElementById("login-form")
|
||||
form.addEventListener("submit", submit)
|
||||
}
|
||||
Reference in New Issue
Block a user