content icon indicating copy to clipboard operation
content copied to clipboard

Search: Missing search data

Open EmileSpecs opened this issue 1 year ago • 1 comments

Environment


  • Operating System: Linux
  • Node Version: v18.20.3
  • Nuxt Version: 3.13.2
  • CLI Version: 3.14.0
  • Nitro Version: 2.9.7
  • Package Manager: [email protected]
  • Builder: -
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

https://github.com/EmileSpecs/nuxtcontentsearch

Describe the bug

Using the playground minimal example I added all the necessary setup steps to get search to work.

I however het the error: Missing search data

Can't find any information about anyone having this issue and I don't see anything that I've missed configuring search.

Can someone please assist?

Thanks!

Additional context

No response

Logs

No response

EmileSpecs avatar Oct 05 '24 17:10 EmileSpecs

This is because the await request will be executed once when the server renders, if you put it in the function will not happen Missing search data.

<script setup>
const search = ref("");
const results = ref([]);

const handleSearch = async () => {
    results.value = await searchContent(search);
}
</script>

<template>
	<main>
		<input v-model="search" />
        <button @click="handleSearch">search</button>

		<pre>{{ results }} </pre>
	</main>
</template>

However, he will have a strange warning that will ask you to replace 'searchContent' with '$fetch'

Image

meorionel avatar Oct 20 '24 03:10 meorionel

@sooooooooooooooooootheby thanks, that solved it.

EmileSpecs avatar Oct 23 '24 09:10 EmileSpecs