2021-02-25 11:46:24 +01:00
|
|
|
function HttpGetter(): void {}
|
2021-02-12 07:32:08 +01:00
|
|
|
|
2021-02-25 11:46:24 +01:00
|
|
|
HttpGetter.prototype.get = filename => new Promise((whohoo, doh) => {
|
|
|
|
const xhr = new XMLHttpRequest();
|
|
|
|
xhr.addEventListener('load', (e) => {
|
|
|
|
if (xhr.status === 200) {
|
|
|
|
whohoo(xhr.responseText);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
doh('failed with status ' + xhr.status + ': ' + xhr.statusText);
|
|
|
|
});
|
|
|
|
xhr.open('GET', filename);
|
|
|
|
xhr.send();
|
|
|
|
});
|
2021-02-12 07:32:08 +01:00
|
|
|
|
|
|
|
export {
|
|
|
|
HttpGetter
|
|
|
|
};
|