Fixed handling of incorrect JSONs
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user