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 <to@itoh.at>

---------

Co-authored-by: ITOH <to@itoh.at>
This commit is contained in:
Fleny
2025-01-16 22:26:54 -06:00
committed by GitHub
co-authored by ITOH
parent 9914d38797
commit d8cfccb914
+2 -2
View File
@@ -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