From 695e1f3932837a49190568ecc10eacf5315fa57f Mon Sep 17 00:00:00 2001 From: Jack Michaud Date: Wed, 4 Jan 2023 14:17:02 -0500 Subject: [PATCH] refactor: avoid using Response.clone() --- website/src/lib/oasst_api_client.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/website/src/lib/oasst_api_client.ts b/website/src/lib/oasst_api_client.ts index ce61e591..45a0859e 100644 --- a/website/src/lib/oasst_api_client.ts +++ b/website/src/lib/oasst_api_client.ts @@ -30,11 +30,12 @@ export default class OasstApiClient { } if (resp.status >= 300) { + const errorText = await resp.text(); try { - const error = await resp.clone().json(); + const error = JSON.parse(errorText); throw new OasstError(error.message, error.error_code, resp.status); } catch (e) { - throw new OasstError(await resp.text(), 0, resp.status); + throw new OasstError(errorText, 0, resp.status); } }