Hi,
i’m trying to implement instantsearch on my website, with algoliasearch-lite & instantsearch.
i’ve follow the documentation step by step to have a working and simple POC.
But i don’t know why, Hits widget is throwing this error :
Uncaught (in promise) Error: Template must be 'string' or 'function', was 'undefined' (key: item)
here is my hits widget configuration :
instantsearch.widgets.hits({
container: '#hit-template',
templates: {
item(hit) {
return `
<h2>
${hit.__hitIndex}:
${instantsearch.highlight({ attribute: 'name', hit })}
</h2>
<p>${hit.description}</p>
`;
},
},
})
as you can see, this is the example provided by the docs.
I’m loading algoliasearch and instantsearch locally (no cdn or npm), XHR request is getting results in the network view :
{,…}
results: [{hits: [{name: "Couette 4 saisons en duvet de canard ALPILLES",…},…], nbHits: 322, page:
0,…}]
0: {hits: [{name: "Couette 4 saisons en duvet de canard ALPILLES",…},…], nbHits: 322, page: 0,…}
exhaustiveNbHits: true
hits: [{name: "Couette 4 saisons en duvet de canard ALPILLES",…},…]
hitsPerPage: 20
index: "XXXX" (==> is replaced with a valid indexName)
nbHits: 322
nbPages: 17
page: 0
params: "query=coue&highlightPreTag=__ais-highlight__&highlightPostTag=__%2Fais-
highlight__&facets=%5B%5D&tagFilters=&filters=type_id%3Agrouped"
processingTimeMS: 2
query: "coue"
I don’t get what i’m missing…
any help would be appreciated
thanks