summaryrefslogtreecommitdiffstats
path: root/src/renderer
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2018-12-08 14:41:03 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2018-12-08 14:41:03 +0100
commit84caf3ba5baf6481b12112ae12a0f79a4f7a6e98 (patch)
tree0d86313cdab16b77b570a96b7922a81388fcada2 /src/renderer
parent69b494f844fc6af1f5e4862ebc93813d598f83c4 (diff)
downloadrpgedit-84caf3ba5baf6481b12112ae12a0f79a4f7a6e98.tar
rpgedit-84caf3ba5baf6481b12112ae12a0f79a4f7a6e98.zip
Switch from XMLHttpRequest to fetch API
Diffstat (limited to 'src/renderer')
-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> {