understading promises-2

This commit is contained in:
2017-02-14 00:41:33 -08:00
parent aa4d767204
commit dea221f83e
5 changed files with 58 additions and 26 deletions

View File

@@ -1,10 +1,9 @@
let url = "rates.json";
import * as service from './rate-service-mock';
fetch(url)
.then(response => response.json())
service.findAll()
.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;
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));