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