-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.js
42 lines (39 loc) · 1.2 KB
/
main.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
39
40
41
42
const {Auth} = require('two-step-auth');
window.signUp=async function(){
let res= await fetch("http://localhost:3000/users");
let data=await res.json();
console.log(data);
let flag=true;
let providedEmail=document.querySelector("#form input[type='email']").value;
let name=document.querySelector("#form input[type='text']").value;
data.forEach((element)=>{
if(element.email == providedEmail){
flag=false;
console.log("Hello");
alert("Email already exists");
}
})
if(flag){
try {
const res = await Auth(providedEmail, "Masai Quora");
let otp=res.OTP;
let body={
name,
providedEmail,
otp
};
let post= await fetch('http://localhost:3000/tempdata',{
method:"POST",
body:JSON.stringify(body),
headers:{
"Content-Type":"application/json"
}
});
let data = await post.json();
console.log(data);
window.location.href="otp.html";
} catch (error) {
console.log(error)
}
}
}