Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>

<html lang="en">

<head>

<title>Object Oriented Programming</title>

<script src="javascript.js"></script>

</head>

<body>

<h1>Exchange rate</h1>
<input type="text" name="" value="">
<button type="button" name="button">Find out exchange rates</button>
<h3>For Euro, type "EUR" // For US Dollar, type "USD" // For Sterling Pound, type "GBP"</h3>
<h4></h4>


</body>


</html>
27 changes: 27 additions & 0 deletions javascript.js
Original file line number Diff line number Diff line change
@@ -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')
});
}