Skip to content

Commit

Permalink
echo null for no data found
Browse files Browse the repository at this point in the history
  • Loading branch information
baxiry committed Oct 12, 2024
1 parent 244607e commit 7a766ee
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions static/shell.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ queryInput.addEventListener('keydown', function(event) {

// handle & send query
if ((event.metaKey || event.altKey ) && event.key === 'Enter' ) {
console.log("with Enter: ", queryInput)
sendQuery(queryInput)
return
}
Expand All @@ -65,15 +64,19 @@ queryInput.addEventListener('keydown', function(event) {
function HandleResponse(response) {
$('#examples').hide();
$('#data').html("<div><div>");
if (response == "") {
$('#data').html(`<pre><span>null</span></pre>`);
$('#data').fadeIn(400);
return;
}

if (pretty) {
let Data = prettyJSON(response)
$('#data').html(`<pre><span>${Data}</span></pre>`);
$('#data').fadeIn(400);
return;
}

data = JSON.parse(response);

if (!Array.isArray(data)) {
let obj = JSON.stringify(data)
$('#data').append(`<pre><span>${obj}</span></pre>`);
Expand Down

0 comments on commit 7a766ee

Please sign in to comment.