diff --git a/index.html b/index.html new file mode 100644 index 0000000..2487075 --- /dev/null +++ b/index.html @@ -0,0 +1,25 @@ + + + + + + + Object Oriented Programming + + + + + + + +

Exchange rate

+ + +

For Euro, type "EUR" // For US Dollar, type "USD" // For Sterling Pound, type "GBP"

+

+ + + + + + \ No newline at end of file diff --git a/javascript.js b/javascript.js new file mode 100644 index 0000000..b0d951c --- /dev/null +++ b/javascript.js @@ -0,0 +1,27 @@ +document.querySelector('button').addEventListener('click', getFetch) + + + +function getFetch(){ + const currency = document.querySelector('input').value + const url = 'https://api.ratesapi.io/api/latest?base='+currency + let storedResults = [] + + + + fetch(url) + .then(res => res.json()) // parse response as JSON + .then(data => { + console.log(JSON.stringify(data.rates, null, 4)) + + + document.querySelector('h4').innerText = JSON.stringify(data.rates, null, 4) + + + + + }) + .catch(err => { + console.log('error') + }); +} \ No newline at end of file