-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
56 lines (46 loc) · 1.58 KB
/
index.html
File metadata and controls
56 lines (46 loc) · 1.58 KB
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
51
52
53
54
55
56
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>test js</title>
</head>
<body>
<h1>Choose only one button</h1>
<h2>Getting pair for your request</h2>
<form>
<input type="text" id="input_1" placeholder="Sent currency id"><br>
<input type="text" id="input_2" placeholder="Received currency id">
</form>
<button onclick="test()">Start function</button>
<h2>Search unique courses</h2>
<button onclick="testing()">Get all the most favourable rates</button>
<script src="md5.min.js"></script>
<script>
function testing() {
const url = 'http://localhost:3000/courses/getAllCourses'
fetch(url, { mode: 'cors' })
.then(data => data.json())
.then(data => console.log(data))
.catch(e => {})
}
async function test() {
const sent_currency = document.getElementById('input_1').value
const received_currency = document.getElementById('input_2').value
const url = `http://127.0.0.1:3000/courses/getPair/${sent_currency}/${received_currency}`
const method = 'GET'
const iv = '2d95623a1685581c746ffe269a2a66f2'
const concatenated = [sent_currency, received_currency, iv].join(':')
const hash = md5(concatenated)
const base64 = window.btoa(hash)
const options = {
mode: 'cors',
headers: { base64 }
}
fetch(url, options)
.then(data => data.json())
.then(val => console.log(val))
.catch(e => {})
}
</script>
</body>
</html>