From 585067bc5f1a6c1a9f08089d59dbd006f223c8bf Mon Sep 17 00:00:00 2001 From: Adam Bem Date: Thu, 18 May 2023 16:23:49 +0200 Subject: [PATCH] Fixed handling of incorrect JSONs --- Frontend/assets/scripts/tools/mock/uianimation.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Frontend/assets/scripts/tools/mock/uianimation.js b/Frontend/assets/scripts/tools/mock/uianimation.js index b8aed5c..ae90596 100644 --- a/Frontend/assets/scripts/tools/mock/uianimation.js +++ b/Frontend/assets/scripts/tools/mock/uianimation.js @@ -88,10 +88,13 @@ async function formatJSON(json) { var result = await fetch(request).then(response => { return response.text().then(function (text) { - return JSON.parse(text); + var json = JSON.parse(text); + json.status = response.status; + return json; }); }); + console.log(result); return result; } @@ -127,8 +130,14 @@ function showRequestBody(element){ switch(historyJson[element.id].headers["content-type"]){ case "application/json":{ formatJSON(historyRequestBody).then(function(result) { - popupContent.innerText = result.data; - highlightSyntax('code-highlight-content'); + + if (result.status == "200") { + popupContent.innerText = result.data; + highlightSyntax('code-highlight-content'); + } + else { + popupContent.innerText = historyRequestBody; + } }); break; }