-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.js
50 lines (46 loc) · 1.29 KB
/
client.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
43
44
45
46
47
48
49
50
$(".success").hide();
function get(){
fetch("http://localhost:3000/btcaddr",
{headers: {'Content-Type': 'application/json'}})
.then(res => res.json())
.then(data => console.log(data));
}
async function createAccount(addr, sig){
var data = {"addr": addr, "sig": sig}
var num;
await fetch("http://localhost:3000/btcaddr",
{
headers: {
'Content-Type': 'application/json'
},
method: "POST",
body: JSON.stringify(data)
})
.then(res => num=res.status);
if(num==201){
$(".sign-in-form").hide();
$(".successtxt").text("You have successfully created an account");
$(".successimg").attr("src", "img/giphy.gif");
$(".success").show();
}
}
async function signIn(addr, sig){
var input = {"addr": addr, "sig": sig}
var num;
await fetch("http://localhost:3000/btcaddr/login",
{
headers: {
'Content-Type': 'application/json'
},
method: "POST",
body: JSON.stringify(input)
})
.then(res => num=res.status);
if(num==200){
console.log("success");
$(".sign-in-form").hide();
$(".successtxt").text("You have successfully signed in");
$(".successimg").attr("src", "img/giphy.gif");
$(".success").show();
}
}