-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
41 lines (36 loc) · 1.13 KB
/
App.js
File metadata and controls
41 lines (36 loc) · 1.13 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
const form = document.querySelector('#searchForm');
const res= document.querySelector('#tablemenu');
var upd;
form.addEventListener('submit',(e)=>{
if(upd)
{
clearTimeout(upd);
}
e.preventDefault();
const ctype = form.elements.coinType.value;
fetchPrice(ctype);
})
const fetchPrice= async(ctype)=>{
const r=await axios.get(`https://api.coinstats.app/public/v1/coins/${ctype}?currency=INR`);
const price= r.data.coin.price;
const volume= r.data.coin.volume;
const Change= r.data.coin.priceChange1d;
res.innerHTML = `
<tr style='background-color:orange; color:black;font-weight:700;'>
<td>Property</td>
<td>Value</td>
</tr>
<tr style='background-color:white; color:black;'>
<td>${ctype}</td>
<td>${price} - INR</td>
</tr>
<tr style='background-color:white; color:black;'>
<td>Volume</td>
<td>${volume}</td>
</tr>
<tr style='background-color:white; color:black;'>
<td>Change</td>
<td>${Change}</td>
</tr>`;
upd= setTimeout(()=>fetchPrice(ctype), 30000);
}