From 5a4a46f13025776362e285e8e0ae7dfc46aaf5b5 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 28 Oct 2022 14:09:39 -0700 Subject: [PATCH] Remove promise and fetch shims and use await for fetch Fixes #4222 --- demo/client.ts | 20 +++++++++----------- demo/index.html | 2 -- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/demo/client.ts b/demo/client.ts index 5b561a8c..1f8ac417 100644 --- a/demo/client.ts +++ b/demo/client.ts @@ -302,7 +302,7 @@ function createTerminal(): void { }); // fit is called within a setTimeout, cols and rows need this. - setTimeout(() => { + setTimeout(async () => { initOptions(term); // TODO: Clean this up, opt-cols/rows doesn't exist anymore (document.getElementById(`opt-cols`) as HTMLInputElement).value = term.cols; @@ -312,16 +312,14 @@ function createTerminal(): void { // Set terminal size again to set the specific dimensions on the demo updateTerminalSize(); - fetch('/terminals?cols=' + term.cols + '&rows=' + term.rows, { method: 'POST' }).then((res) => { - res.text().then((processId) => { - pid = processId; - socketURL += processId; - socket = new WebSocket(socketURL); - socket.onopen = runRealTerminal; - socket.onclose = runFakeTerminal; - socket.onerror = runFakeTerminal; - }); - }); + const res = await fetch('/terminals?cols=' + term.cols + '&rows=' + term.rows, { method: 'POST' }); + const processId = await res.text(); + pid = processId; + socketURL += processId; + socket = new WebSocket(socketURL); + socket.onopen = runRealTerminal; + socket.onclose = runFakeTerminal; + socket.onerror = runFakeTerminal; }, 0); } diff --git a/demo/index.html b/demo/index.html index a65b8bbc..83877d22 100644 --- a/demo/index.html +++ b/demo/index.html @@ -10,8 +10,6 @@ - -

xterm.js: A terminal for the web