From 26af5e045064d1f67ce9428eb6f50d6b3a7303e4 Mon Sep 17 00:00:00 2001 From: Marcel Eichner Date: Wed, 19 Jun 2024 22:40:01 +0200 Subject: [PATCH] fix: body used already error fix #340 (#346) --- lib/httpadapter/fetchadapter.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/httpadapter/fetchadapter.js b/lib/httpadapter/fetchadapter.js index 030c092..6085439 100644 --- a/lib/httpadapter/fetchadapter.js +++ b/lib/httpadapter/fetchadapter.js @@ -42,10 +42,11 @@ class FetchAdapter { if (fullResponse) { return res; } + const rawResponseBody = await res.text(); try { - return await res.json(); + return JSON.parse(rawResponseBody); } catch (e) { - throw new HttpError(await res.text(), { + throw new HttpError(rawResponseBody, { code: res.statusCode }); }