-
Notifications
You must be signed in to change notification settings - Fork 0
/
signup.js
38 lines (34 loc) · 1.06 KB
/
signup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const signupForm = document.getElementById("signup-form");
const emailInput = document.getElementById("email");
const passwordInput = document.getElementById("password");
const nameInput = document.getElementById("name");
const phoneInput = document.getElementById("phone");
signupForm.addEventListener("submit", (event) => {
event.preventDefault();
const email = emailInput.value;
const password = passwordInput.value;
const name = nameInput.value;
const phone = phoneInput.value;
fetch("/api/signup", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
email,
password,
name,
phone,
}),
})
.then((response) => {
if (response.status === 200) {
window.location.href = "/login.html";
} else {
alert("Signup failed");
}
})
.catch((error) => {
console.log(error);
});
});