diff --git a/examples/js/app.ts b/examples/js/app.ts index 52b7049e1..980842dc7 100644 --- a/examples/js/app.ts +++ b/examples/js/app.ts @@ -16,33 +16,35 @@ autocomplete({ container: '#autocomplete', debug: true, // dropdownPlacement: 'start', - getSources() { - return [ - { - getInputValue: ({ suggestion }) => suggestion.query, - getSuggestions({ query }) { - return getAlgoliaHits({ - searchClient, - queries: [ - { - indexName: 'instant_search_demo_query_suggestions', - query, - params: { - hitsPerPage: 4, - }, - }, - ], - }); + getSources({ query }) { + return getAlgoliaHits({ + searchClient, + queries: [ + { + indexName: 'instant_search_demo_query_suggestions', + query, + params: { + hitsPerPage: 4, + }, }, - templates: { - item({ item }) { - return reverseHighlightItem({ - item, - attribute: 'query', - }); + ], + }).then((hits) => { + return [ + { + getInputValue: ({ suggestion }) => suggestion.query, + getSuggestions() { + return hits; + }, + templates: { + item({ item }) { + return reverseHighlightItem({ + item, + attribute: 'query', + }); + }, }, }, - }, - ]; + ]; + }); }, });