How to implement instantsearch example in pure JS #1244
                  
                    
                      aboriG7294
                    
                  
                
                  started this conversation in
                General
              
            Replies: 2 comments 2 replies
-
| You can just remove anything TypeScript-specific to convert it into a JavaScript code, for example with https://github.com/algolia/autocomplete/blob/next/examples/starter/app.tsx: import { autocomplete } from '@algolia/autocomplete-js';
import '@algolia/autocomplete-theme-classic';
- type AutocompleteItem = {
-   label: string;
-   url: string;
- };
- autocomplete<AutocompleteItem>({
+ autocomplete({
  container: '#autocomplete',
  getSources() {
    return [
      {
        sourceId: 'links',
        getItems({ query }) {
          const items = [
            { label: 'Twitter', url: 'https://twitter.com' },
            { label: 'GitHub', url: 'https://github.com' },
          ];
          return items.filter(({ label }) =>
            label.toLowerCase().includes(query.toLowerCase())
          );
        },
        getItemUrl({ item }) {
          return item.url;
        },
        templates: {
          item({ item }) {
            return item.label;
          },
        },
      },
    ];
  },
}); | 
Beta Was this translation helpful? Give feedback.
                  
                    2 replies
                  
                
            -
| Finally I was able to convert the code, but still have one issue. Here is the code: https://pastebin.com/ECgYyXaQ | 
Beta Was this translation helpful? Give feedback.
                  
                    0 replies
                  
                
            
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
-
Hello!
I have a laravel project with InstantSearch functionality. Now I want to implement also Autocomplete to it.
Given example is written in TypeScript and I don`t know how to combine it with my current pure JS code.
Can someone explain to me how to achieve that ?
Many many thanks!
Beta Was this translation helpful? Give feedback.
All reactions