diff --git a/src/app/_helpers/http-getter.ts b/src/app/_helpers/http-getter.ts index f5c9f65..2f02528 100644 --- a/src/app/_helpers/http-getter.ts +++ b/src/app/_helpers/http-getter.ts @@ -1,16 +1,14 @@ function HttpGetter(): void {} -HttpGetter.prototype.get = filename => new Promise((whohoo, doh) => { - const xhr = new XMLHttpRequest(); - xhr.addEventListener('load', (e) => { - if (xhr.status === 200) { - whohoo(xhr.responseText); - return; +HttpGetter.prototype.get = filename => new Promise((resolve, reject) => { + fetch(filename).then(response => { + if (response.ok) { + resolve(response.json()); + } else { + reject(`failed with status ${response.status} : ${response.statusText}`); } - doh('failed with status ' + xhr.status + ': ' + xhr.statusText); + return; }); - xhr.open('GET', filename); - xhr.send(); }); export {