summaryrefslogtreecommitdiffstats
path: root/src/renderer/util.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/renderer/util.ts')
-rw-r--r--src/renderer/util.ts32
1 files changed, 2 insertions, 30 deletions
diff --git a/src/renderer/util.ts b/src/renderer/util.ts
index cea404b..4fedbd5 100644
--- a/src/renderer/util.ts
+++ b/src/renderer/util.ts
@@ -46,37 +46,9 @@ export class Listenable<T extends any[]> {
}
}
-export function get(url: string): Promise<XMLHttpRequest> {
- return new Promise((resolve, reject) => {
- const xhr = new XMLHttpRequest();
-
- const handleError = () => {
- if (xhr.readyState !== xhr.DONE) {
- reject(new Error('HTTP request ended in state ' + xhr.readyState));
- return;
- }
-
- reject(new Error('HTTP request returned status ' + xhr.status));
- };
-
- xhr.addEventListener('error', handleError);
-
- xhr.addEventListener('load', () => {
- if (xhr.readyState !== xhr.DONE || xhr.status !== 200) {
- handleError();
- return;
- }
-
- resolve(xhr);
- });
-
- xhr.open('GET', url, true);
- xhr.send();
- });
-}
-
export async function getJSON(url: string): Promise<any> {
- return JSON.parse((await get(url)).responseText);
+ const res = await window.fetch(url);
+ return await res.json();
}
export function nextAnimationFrame(): Promise<DOMHighResTimeStamp> {