forked from BipulChau/RevMo-frontend-final-project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforgotpassword.js
34 lines (30 loc) · 1.02 KB
/
forgotpassword.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
let emailInput = document.querySelector("#email");
document.getElementById("email_submit").addEventListener("click", forgotEmail);
async function forgotEmail() {
try {
let res = await fetch(`http://localhost:8080/forgotpassword`,{
method:"POST",
headers: {
"Content-Type" : "application/json"
},
body: JSON.stringify({
email: emailInput.value
}),
});
if (res.status == 202){
alert("Please Check Your Email for the Passoword Reset link!")
}
if (res.status == 401){
data = await res.json();
console.log("401 status gopu");
emailInput.value = "";
console.log("401 status gopu2");
let para = document.querySelector("#error-message");
console.log(`para = ${para}`);
para.style.color = "black";
para.innerHTML = data.message;
}
} catch (error){
console.log(error);
}
}