18 lines
456 B
TypeScript
18 lines
456 B
TypeScript
function HttpGetter(): void {}
|
|
|
|
HttpGetter.prototype.get = (filename) =>
|
|
new Promise((resolve, reject) => {
|
|
const xhr: XMLHttpRequest = new XMLHttpRequest();
|
|
xhr.addEventListener('load', (e) => {
|
|
if (xhr.status === 200) {
|
|
resolve(xhr.responseText);
|
|
return;
|
|
}
|
|
reject('failed with status ' + xhr.status + ': ' + xhr.statusText);
|
|
});
|
|
xhr.open('GET', filename);
|
|
xhr.send();
|
|
});
|
|
|
|
export { HttpGetter };
|