From 1292baa030501c777df8a7edd8cc7ff55c2a81a1 Mon Sep 17 00:00:00 2001 From: Marcel Eichner Date: Mon, 27 Feb 2023 09:49:56 +0100 Subject: [PATCH 1/2] fix: body used already error fix #340 --- 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..9bc2696 100644 --- a/lib/httpadapter/fetchadapter.js +++ b/lib/httpadapter/fetchadapter.js @@ -42,10 +42,11 @@ class FetchAdapter { if (fullResponse) { return res; } + const rawResponseBody = 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 }); } From 2f0a33cf4fb9496cf211018e35017a0b675e4584 Mon Sep 17 00:00:00 2001 From: Marcel Eichner Date: Tue, 18 Jun 2024 13:40:40 +0200 Subject: [PATCH 2/2] fix: adds await --- lib/httpadapter/fetchadapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/httpadapter/fetchadapter.js b/lib/httpadapter/fetchadapter.js index 9bc2696..6085439 100644 --- a/lib/httpadapter/fetchadapter.js +++ b/lib/httpadapter/fetchadapter.js @@ -42,7 +42,7 @@ class FetchAdapter { if (fullResponse) { return res; } - const rawResponseBody = res.text(); + const rawResponseBody = await res.text(); try { return JSON.parse(rawResponseBody); } catch (e) {