From 54d27d5ccdc8d3e3a2069dd60bced555193c3de7 Mon Sep 17 00:00:00 2001 From: Arthur Lu Date: Mon, 12 Dec 2022 15:56:57 -0800 Subject: [PATCH] try promises --- utils.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/utils.js b/utils.js index 2e8450c..c37f2d2 100644 --- a/utils.js +++ b/utils.js @@ -8,6 +8,15 @@ export async function requestTicket (username, password) { "Content-Type": "application/x-www-form-urlencoded" }, body: prms.toString() + }) + .then((response) => { + if (!response.ok) { + throw new Error('Network response was not OK'); + } + return response; + }) + .catch((error) => { + console.error('There has been a problem with your fetch operation:', error); }); let data = await response.json(); return data;