mirror of
https://github.com/discordeno/discordeno.git
synced 2026-09-17 08:47:22 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user