forked from asadayyubi/absorbed-porter-6072
-
Notifications
You must be signed in to change notification settings - Fork 0
/
login2.js
37 lines (31 loc) · 796 Bytes
/
login2.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
fetch("https://mok-api-hola-ex.onrender.com/users")
.then((req)=>{
return req.json();
})
.then((data)=>{
// funCheck(data)
login(data)
})
let email_data=document.getElementById("email")
let password_data=document.getElementById("password")
let login_btn=document.getElementById("login-btn")
function login(data){
console.log(data)
login_btn.addEventListener("click",()=>{
funCheck(data)
})
}
let count=0;
function funCheck(data){
data.forEach(element => {
if(element.email==email_data.value && element.password==password_data.value){
count++;
alert(`Welcome ${element.name}`)
location.href=`product.html`
return;
}
});
if(count==0){
alert("Wrong credential")
}
}