From 605c483d5b5f58924d2ea9b36370aac895530ec7 Mon Sep 17 00:00:00 2001 From: dmahmalat Date: Tue, 12 Mar 2024 01:03:37 -0400 Subject: [PATCH] Continue on parseJSON error (#708) --- static/js/app.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/static/js/app.js b/static/js/app.js index 1c5c5d7..e3a2b6a 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -85,7 +85,14 @@ function apiCall(method, path, params, cb) { return cb({ error: "Query timeout after " + timeout + "s" }); } - cb(jQuery.parseJSON(xhr.responseText)); + var responseText; + try { + responseText = jQuery.parseJSON(xhr.responseText); + } + catch { + responseText = { error: "Failed to parse the JSON response." }; + } + cb(responseText); } }); }