nuxt-modules / algolia

🔎 Algolia module for Nuxt
https://algolia.nuxtjs.org/
MIT License
189 stars 35 forks source link

`findObjects` function not available on `index` object. #104

Closed Agusnez closed 1 year ago

Agusnez commented 1 year ago

Hello,

I was performing a basic demo with:

<script setup>
const algoliaIndex = useAlgoliaInitIndex('test')
console.log(algoliaIndex.appId)
</script>

But the algoliaIndex object only has the search function available, not the findObjects operations that we are supposed to do on the Algolia documentation: https://www.algolia.com/doc/api-client/methods/search/

Is this an expected behaviour? Thanks!

Baroshem commented 1 year ago

Hey @Agusnez

I am not sure about this method. Do you mean that the TS is not suggesting it in the autocomplete or that this method is not available at all?

Maybe you need to load full algoliasearch (not the default lite version) to make it work.

https://algolia.nuxtjs.org/getting-started/configuration#lite

Agusnez commented 1 year ago

Hi @Baroshem,

Thank you very much for your help. The thing that is not working is that the method is not available at all:

Unhandled Promise Rejection: TypeError: index.findObject is not a function.

Let me look into the full algoliasearch, because it might be my case, since I'm using the useInitIndex moethod, not the useAlgoliaInitIndex like the example. (This is because I don't have it available in my installation)

I will post my updates.

Baroshem commented 1 year ago

Hey @Agusnez

I think you have a typo in your method name (gindObject instead of findObjects).

Also, make sure to use useAlgoliaInitIndex at all times. The other method wont work.

Agusnez commented 1 year ago

Hi @Baroshem, I have good news about this.

I was using the previous version of the module @nuxt-modules/algolia. Removing it from the package.json and running npm i @nuxtjs/algolia fixed the issue. Now I see the useAlgoliaInitIndex function.

Thank you very much for your help!

Baroshem commented 1 year ago

@Agusnez I am glad that you have figured it out!

If you will have any questions, please let me know :)