From 8e4f4350e306a1fe6ccd149aed2f42ad7a869f5f Mon Sep 17 00:00:00 2001 From: StephaneBour Date: Mon, 15 Jan 2024 14:31:47 +0100 Subject: [PATCH] fix: is bad response, disable csv export --- src/base.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/base.js b/src/base.js index b781560..e4a56cd 100755 --- a/src/base.js +++ b/src/base.js @@ -103,7 +103,7 @@ function submitCurrentRequestToES() { if (es_data) es_data += "\n"; //append a new line for bulk requests. callES(es_server, es_url, es_method, es_data, null, function (xhr) { - $("#notification").text("").css("visibility", "hidden"); + $("#notification").text("").css("visibility", "hidden"); if (typeof xhr.status == "number" && ((xhr.status >= 400 && xhr.status < 600) || (xhr.status >= 200 && xhr.status < 300) @@ -111,16 +111,15 @@ function submitCurrentRequestToES() { // we have someone on the other side. Add to history sense.history.addToHistory(es_server, es_url, es_method, es_data); - let value = xhr.responseText; try { value = JSON.stringify(JSON.parse(value), null, 3); - } catch (e) { - } sense.output.getSession().setValue(value); - sense.output.getSession().setCsv(ConvertSourceToCSV(inJson.hits.hits)); + if (JSON.parse(value) && JSON.parse(value).hits && JSON.parse(value).hits.hits) { + sense.output.getSession().setCsv(ConvertSourceToCSV(JSON.parse(value)?.hits?.hits)); + } } else { sense.output.getSession().setValue("Request failed to get to the server (status code: " + xhr.status + "):" + xhr.responseText); }