From ba6ee3b130aa7d6f94162938d01fe157ce6b6cae Mon Sep 17 00:00:00 2001 From: Andrew Prokhorenkov Date: Fri, 16 Sep 2022 02:24:50 -0500 Subject: [PATCH] fix: add extra then in the chain to resolve response from fetch Not sure how it works, seems like Promise inside ternary operator doesn't work as expected, so either extra then or await before ternary operator --- src/components/Utils/queries.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/Utils/queries.js b/src/components/Utils/queries.js index 5f5608ee..026e8446 100644 --- a/src/components/Utils/queries.js +++ b/src/components/Utils/queries.js @@ -361,7 +361,9 @@ export const downloadDataFromGuppy = ( 'Content-Type': 'application/json', }, body: JSON.stringify(queryBody), - }).then((res) => (JSON_FORMAT ? res.json() : jsonToFormat(res.json(), format))); + }) + .then((r) => r.json()) + .then((res) => (JSON_FORMAT ? res : jsonToFormat(res, format))); } return askGuppyForRawData(path, type, fields, filter, sort, 0, totalCount, accessibility, format) .then((res) => {