Fixed handling of incorrect JSONs

This commit is contained in:
2023-05-18 16:23:49 +02:00
parent 8e7691ee95
commit 585067bc5f

View File

@@ -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;
}