Closed aldenquimby closed 4 months ago
Hi, thanks for your report. There is no error catching for Algolia sources at the library level currently. As a workaround you can catch errors at the search client level and forward them to the source in place of result items:
const algoliaClient = algoliasearch(appId, apiKey);
const searchClient = {
...algoliaClient,
search(queries) {
return algoliaClient.search(queries).catch((error) => {
return { results: [{ hits: [{ error }] }] };
});
},
};
You will then be able to detect the presence of item.error
in your source's item template and show a message accordingly.
@dhayab perfect, thank you!
Description
Reproduction
Steps
Create autocomplete with multiple algolia sources:
Turn off your internet so all requests will fail
Type into search input
Expected behavior
error
, or (b) there's a way to catch errors and set status + display a messageActual behavior
Environment