diff options
Diffstat (limited to 'src/index.ts')
| -rw-r--r-- | src/index.ts | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/src/index.ts b/src/index.ts index 5845a7d..c101b0f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -36,19 +36,16 @@ export default class Irc { } async poll(): Promise<void> { - console.log("polling"); - fetch(this.messages.url + "poll") - .then(msg => - msg.json().then(msg => { - this.messages.addMessage(msg); - const update = - document.activeElement === this.input ? "bottom" : "relative"; + .then(async res => { + const msg = await res.json(); + this.messages.addMessage(msg); + const update = + document.activeElement === this.input ? "bottom" : "relative"; - this.helpers.updateScrollbar(update); - this.poll(); - }) - ) + this.helpers.updateScrollbar(update); + this.poll(); + }) .catch(this.poll); } |
