Advertisement
Rezzy321

Untitled

May 1st, 2021
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. const button1 = document.querySelector('#eth');
  2. const list = document.querySelector('#price');
  3.  
  4.  
  5. const addPrice = async() => {
  6. const pricee = await checkPrice();
  7. console.log(pricee)
  8. const newLI = document.createElement('LI');
  9. newLI.append(pricee);
  10. list.append(newLI)
  11. }
  12.  
  13.  
  14.  
  15. const checkPrice = async () => {
  16. axios.get('https://api.cryptonator.com/api/ticker/eth-aud')
  17. .then(res => {
  18. //.then(function(res) {
  19. console.log(res.data.ticker.price)
  20. return res.data.ticker.price
  21.  
  22. })
  23. .catch(err => {
  24. console.log('Sorry, error!')
  25. return 'Sorry, error!'
  26. })
  27. }
  28.  
  29. button1.addEventListener('click', addPrice)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement