0

In my ionic app, I'm trying to implement Algolia. I have this code:

search: any;

ngOnInit() {

  this.search = instantsearch({
    searchClient: algoliasearch(
    '5SRF6DY7XY',
    'a2cc46cbc3b02e3f93e1a914fe2528ea'),
    indexName: 'test'
  });

  this.search.addWidget(
    instantsearch.widgets.hits({
      container: '#hits',
    })
  );

  this.search.addWidget(
    instantsearch.widgets.searchBox({
      container: '#search-box'
    })
  );
  this.search.start();



  }

And I'm importing: import * as algoliasearch from 'algoliasearch';

import instantsearch from 'instantsearch.js';
declare var instantsearch: any;

And things compile fine, but then when I go to open my page, I'm getting the error:

Container must be string or HTMLElement. Unable to find #hits

Isn't my '#hits' already a string? Is there something I should be importing that I'm not?

Noah Omdal
  • 89
  • 12
  • sounds more like youre not finding #hits which then returns undefined which isnt String or HTMLElement I asume when you pass a string it expects the id of a container somehwere – jonathan Heindl Apr 25 '19 at 20:39
  • It's supposed to be calling to the hit and search-box js documents in instantsearch.js, but for some reason it isn't picking them up with 'hit' and 'search-box' – Noah Omdal Apr 25 '19 at 21:06
  • from instantsearch container : CSS Selector or HTMLElement to insert the widget. this means we need the definition of the element assinged with #hits – jonathan Heindl Apr 25 '19 at 21:08

0 Answers0