lucos_search_component 1.0.18 → 1.0.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -5899,9 +5899,15 @@ class LucosSearchComponent extends HTMLSpanElement {
5899
5899
  error.userMessage = userMessage;
5900
5900
  throw error;
5901
5901
  }
5902
- const data = await response.json();
5903
5902
  if (!response.ok) {
5904
- const error = new Error(`Received ${response.status} error from search endpoint: ${data["message"]}`);
5903
+ let detail;
5904
+ try {
5905
+ const data = await response.json();
5906
+ detail = data["message"];
5907
+ } catch(_) {
5908
+ // Non-JSON body (e.g. nginx HTML error page) — detail stays undefined
5909
+ }
5910
+ const error = new Error(`Received ${response.status} error from search endpoint: ${detail}`);
5905
5911
  if (response.status === 502 || response.status === 503) {
5906
5912
  error.userMessage = 'Search backend is currently unavailable — please try again later.';
5907
5913
  } else {
@@ -5909,6 +5915,7 @@ class LucosSearchComponent extends HTMLSpanElement {
5909
5915
  }
5910
5916
  throw error;
5911
5917
  }
5918
+ const data = await response.json();
5912
5919
  const results = data.hits.map(result => {
5913
5920
  return {...result, ...result.document}
5914
5921
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lucos_search_component",
3
- "version": "1.0.18",
3
+ "version": "1.0.19",
4
4
  "description": "Web Components for searching lucOS data",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -256,9 +256,15 @@ class LucosSearchComponent extends HTMLSpanElement {
256
256
  error.userMessage = userMessage;
257
257
  throw error;
258
258
  }
259
- const data = await response.json();
260
259
  if (!response.ok) {
261
- const error = new Error(`Received ${response.status} error from search endpoint: ${data["message"]}`);
260
+ let detail;
261
+ try {
262
+ const data = await response.json();
263
+ detail = data["message"];
264
+ } catch(_) {
265
+ // Non-JSON body (e.g. nginx HTML error page) — detail stays undefined
266
+ }
267
+ const error = new Error(`Received ${response.status} error from search endpoint: ${detail}`);
262
268
  if (response.status === 502 || response.status === 503) {
263
269
  error.userMessage = 'Search backend is currently unavailable — please try again later.';
264
270
  } else {
@@ -266,6 +272,7 @@ class LucosSearchComponent extends HTMLSpanElement {
266
272
  }
267
273
  throw error;
268
274
  }
275
+ const data = await response.json();
269
276
  const results = data.hits.map(result => {
270
277
  return {...result, ...result.document}
271
278
  });