Skip to content

Commit

Permalink
fix: is bad response, disable csv export
Browse files Browse the repository at this point in the history
  • Loading branch information
StephaneBour committed Jan 15, 2024
1 parent c0859e0 commit 8e4f435
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,24 +103,23 @@ 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)
)) {
// 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);
}
Expand Down

0 comments on commit 8e4f435

Please sign in to comment.