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 { } } -export function get(url: string): Promise { - 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 { - return JSON.parse((await get(url)).responseText); + const res = await window.fetch(url); + return await res.json(); } export function nextAnimationFrame(): Promise {