Want to trigger useFetch after min 3 chars and also wait for 100 mS after each char.
Have also a strange thing that the value of searchTerm.value is always empty.
const searchTerm = ref('')
const debouncedFn = useDebounceFn(() => {
if (searchTerm.value && searchTerm.value.length >= 3) {
execute()
}
}, {delay: 50})
const {data, execute } = await useFetch('url', {
headers: {
access_token: 'token'
},
query: {
query: **searchTerm.value** >> always be empty
}
watch: [
debouncedFn
],
immediate: false,
})
<template>
<input v-model="searchTerm">
</template>