nuxt-modules / algolia

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

Problem using search() outside of onMounted() hook #60

Closed dmitryT93 closed 2 years ago

dmitryT93 commented 2 years ago

Have a problem displaying SSR data if i use code from example

<script setup>
const { result, search } = useSearch('test_index') // pass your index name as param

onMounted(async () => {
  await search({ query: 'Samsung' });
})
</script>

all work well, but data loaded after page load, but I would like to receive data before the page is fully loaded

if i try something like this

<script setup>
const { result, search } = useSearch('test_index') // pass your index name as param
await search({ query: 'Samsung' });
</script>

i catch 500 error, text: XMLHttpRequest is not defined

"nuxt": "3.0.0-rc.1",
"@nuxtjs/algolia": "^0.9.2",

How could I solve this problem? Thanks for the answer

Baroshem commented 2 years ago

Hey @dmitryT93

This module does not yet support the SSR execution, but we are already working on it. You can follow #46 to get more details.

I will try to work on it as well this week to make it ready for the new release :)

Baroshem commented 2 years ago

I tried debugging it and it seems that the NodeHTTPRequester does not work with Vite out of the box. We have to wait for the official support.

Baroshem commented 2 years ago

I will close this issue in favor of #63