fvasconcelos

Untitled

Dec 4th, 2020
474
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. async function fetchCurrency(currency) {
  2.   const response = await fetch(`https://economia.awesomeapi.com.br/json/${currency}-BRL`);
  3.   const data = await response.json();
  4.  
  5.   if (currency === 'USD'){
  6.       const currentUSD = data[0].bid.replace(".", ",");
  7.       usd = data[0].bid;
  8.       document.querySelector('#usd').insertAdjacentHTML('beforeend', currentUSD);
  9.   } else if (currency === 'EUR'){
  10.       const currentEUR = data[0].bid.replace(".", ",");
  11.       eur = data[0].bid;
  12.       document.querySelector('#eur').insertAdjacentHTML('beforeend', currentEUR);
  13.   } else if (currency === 'CAD'){
  14.       const currentCAD = data[0].bid.replace(".", ",");
  15.       cad = data[0].bid;
  16.       document.querySelector('#cad').insertAdjacentHTML('beforeend', currentCAD);
  17.   }
  18. }
RAW Paste Data