diff --git a/Frontend/assets/scripts/tools/mock/uianimation.js b/Frontend/assets/scripts/tools/mock/uianimation.js index 29c393a..a25be77 100644 --- a/Frontend/assets/scripts/tools/mock/uianimation.js +++ b/Frontend/assets/scripts/tools/mock/uianimation.js @@ -77,7 +77,7 @@ function showHeadersHistory(element){ showPopup(); } -function formatXML(xml) { +async function formatXML(xml) { const address = window.location.protocol + "//" + window.location.hostname + ":" + 8082 + "/prettify"; var data = { data: xml, @@ -86,27 +86,19 @@ function formatXML(xml) { version: "1.0" } - console.log("formattedXML"); - fetch(address, { - method: 'POST', - body: JSON.stringify(data) - }) - .then(async (response) => { - const promise = response.json(); - if (!response.ok) { - throw Error(await promise); - } - return promise; - }) - .then((data) => { - document.getElementById('code-highlight-content').innerText = data.result; - highlightSyntax('code-highlight-content'); - //console.log(data.result); - }) - .catch((error) => { - console.error('Error:', error); + var init = { + body: JSON.stringify(data), + method: "POST" + }; + var request = new Request(address, init); + + var result = await fetch(request).then(response => { + return response.text().then(function (text) { + return JSON.parse(text); }); - + + }); + return result; } function showRequestBody(element){ @@ -138,15 +130,22 @@ function showRequestBody(element){ break; } case "application/xml":{ - //document.getElementById('code-highlight-content').innerText = historyRequestBody; - formatXML(historyRequestBody); + document.getElementById('code-highlight-content').innerText = ""; + formatXML(historyRequestBody).then(function(result) { + if (result.status == "OK") { + document.getElementById('code-highlight-content').innerText = result.result; + highlightSyntax('code-highlight-content'); + } + else { + document.getElementById('code-highlight-content').innerText = historyRequestBody; + } + + }); break; } - default:{ - requestBody = ''+historyRequestBody+''; - document.getElementById('history-request-body-content').innerText = requestBody; + document.getElementById('code-highlight-content').innerText = historyRequestBody; hljs.highlightElement(document.getElementById('history-request-body-content')); } }