Files
digifi-PayStack/client/login.js
T
tolu-paystack a4daf209bc initial commit
2022-08-02 13:57:59 +01:00

28 lines
843 B
JavaScript

window.addEventListener("DOMContentLoaded", async () => {
const form = document.getElementById("signin-form");
if (form) {
form.addEventListener("submit", async (e) => {
e.preventDefault();
const email = document.getElementById("email").value;
const customer = await fetch("/create-customer", {
method: "post",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
email: email,
}),
})
.then((res) => res.json())
.catch((error) => console.log(error));
window.localStorage.setItem("customer_email", email);
window.localStorage.setItem("customer_code", customer.customer_code);
window.localStorage.setItem("customer_id", customer.id);
window.location.href = "/account.html";
});
}
});