From 8e255c98286c5540678c7272ff9a02ea138655ed Mon Sep 17 00:00:00 2001 From: godslayerakp <74981904+RedMan13@users.noreply.github.com> Date: Mon, 10 Jul 2023 19:52:01 -0700 Subject: [PATCH 1/3] patched value handling order --- extensions/godslayerakp/http.js | 48 ++++++++++++++++----------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/extensions/godslayerakp/http.js b/extensions/godslayerakp/http.js index 6d7e6c5b58..4a0f572d12 100644 --- a/extensions/godslayerakp/http.js +++ b/extensions/godslayerakp/http.js @@ -590,34 +590,34 @@ // eslint-disable-next-line require-await async sendRequest(args) { const url = Cast.toString(args.url); - - this.clearAll(); + const options = this.request.options + + this.clearAll() this.response.url = url; - Scratch.fetch(url, this.request.options) - .then(res => { - // @ts-ignore - this.response.status = res.status; - this.response.headers = res.headers; - this.response.statusText = res.statusText; - if (res.ok) { - this.request.success = true; - this.request.events.activate('reqSuccess'); - } else { - this.request.fail = true; - this.request.events.activate('reqFail'); - } - this.request.end = true; - return res.text(); - }) - .then(body => this.response.text = body) - .catch(err => { - this.response.error = String(err); - console.warn('request failed with error', err); + try { + const res = await Scratch.fetch(url, options) + // @ts-ignore + this.response.status = res.status; + this.response.headers = res.headers; + this.response.statusText = res.statusText; + if (res.ok) { + this.request.success = true; + this.request.events.activate('reqSuccess'); + } else { this.request.fail = true; - this.request.end = true; this.request.events.activate('reqFail'); - }); + } + this.request.end = true; + const body = await res.text() + this.response.text = body + } catch (err) { + this.response.error = String(err); + console.warn('request failed with error', err); + this.request.fail = true; + this.request.end = true; + this.request.events.activate('reqFail'); + } } /* extra stuff for when its missing something */ From 41cb75c079f1f816caa2f4ed32f83b2c9f67b316 Mon Sep 17 00:00:00 2001 From: godslayerakp <74981904+RedMan13@users.noreply.github.com> Date: Mon, 10 Jul 2023 19:54:56 -0700 Subject: [PATCH 2/3] fix eslint --- extensions/godslayerakp/http.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/extensions/godslayerakp/http.js b/extensions/godslayerakp/http.js index 4a0f572d12..6fc3e68fba 100644 --- a/extensions/godslayerakp/http.js +++ b/extensions/godslayerakp/http.js @@ -590,13 +590,13 @@ // eslint-disable-next-line require-await async sendRequest(args) { const url = Cast.toString(args.url); - const options = this.request.options + const options = this.request.options; - this.clearAll() + this.clearAll(); this.response.url = url; try { - const res = await Scratch.fetch(url, options) + const res = await Scratch.fetch(url, options); // @ts-ignore this.response.status = res.status; this.response.headers = res.headers; @@ -609,8 +609,8 @@ this.request.events.activate('reqFail'); } this.request.end = true; - const body = await res.text() - this.response.text = body + const body = await res.text(); + this.response.text = body; } catch (err) { this.response.error = String(err); console.warn('request failed with error', err); From b3c52e18fdb52b97b986a05ea33bc4be115c5be6 Mon Sep 17 00:00:00 2001 From: godslayerakp <74981904+RedMan13@users.noreply.github.com> Date: Mon, 10 Jul 2023 19:59:13 -0700 Subject: [PATCH 3/3] eslint is complaining here idk why its so angy abt it but i want it to shut up so --- extensions/godslayerakp/http.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/godslayerakp/http.js b/extensions/godslayerakp/http.js index 6fc3e68fba..46321fa848 100644 --- a/extensions/godslayerakp/http.js +++ b/extensions/godslayerakp/http.js @@ -591,7 +591,7 @@ async sendRequest(args) { const url = Cast.toString(args.url); const options = this.request.options; - + this.clearAll(); this.response.url = url;