From d8cfccb914c78ff08f160e6f0f920c8c67e6b5b9 Mon Sep 17 00:00:00 2001 From: Fleny Date: Fri, 17 Jan 2025 05:26:54 +0100 Subject: [PATCH] feat(rest)!: Parse json body when possibile in rest proxy (#4090) * Parse json body when possibile in rest proxy * Fix typo Co-authored-by: ITOH --------- Co-authored-by: ITOH --- packages/rest/src/manager.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/rest/src/manager.ts b/packages/rest/src/manager.ts index 5494b7edb..ae9437ca5 100644 --- a/packages/rest/src/manager.ts +++ b/packages/rest/src/manager.ts @@ -555,12 +555,12 @@ export function createRestManager(options: CreateRestManagerOptions): RestManage const result = await fetch(`${rest.baseUrl}/v${rest.version}${route}`, rest.createRequestBody(method, options)) if (!result.ok) { - const errText = await result.text().catch(() => null) + const body = (result.headers.get('Content-Type') === 'application/json' ? await result.json() : await result.text()).catch(() => null) error.cause = { ok: false, status: result.status, - body: errText, + body, } throw error