From 8ad1ba514f38b497ad8dab254683c33415e5fbd6 Mon Sep 17 00:00:00 2001 From: Ryan Zaleski Date: Tue, 23 Mar 2021 21:05:12 +0000 Subject: [PATCH] completed project, all working --- index.html | 25 +++++++++++++++++++++++++ javascript.js | 27 +++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 index.html create mode 100644 javascript.js 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