mirror of
https://github.com/Raghu-Ch/ES6-Handson.git
synced 2026-02-10 12:43:01 -05:00
Understanding promises
This commit is contained in:
10
js/ratefinder.js
Normal file
10
js/ratefinder.js
Normal file
@@ -0,0 +1,10 @@
|
||||
let url = "rates.json";
|
||||
|
||||
fetch(url)
|
||||
.then(response => response.json())
|
||||
.then(rates => {
|
||||
let html = '';
|
||||
rates.forEach(rate => html += `<tr><td>${rate.name}</td><td>${rate.years}</td><td>${rate.rate}%</td></tr>`);
|
||||
document.getElementById("rates").innerHTML = html;
|
||||
})
|
||||
.catch(e => console.log(e));
|
||||
Reference in New Issue
Block a user