#community-help

Vue-InstantSearch Default Page Issue with Typesense Integration

TLDR Mehul is having issues setting the default page number with vue-instantsearch and Typesense. Jason suggests asking the vue-instantsearch team and trying the configure widget.

Powered by Struct AI
Jun 19, 2023 (3 months ago)
Mehul
Photo of md5-375f12d6cdbb3bc6accdbd819d657bf3
Mehul
09:55 AM
Hello Team,

I have implemented the vue-instantsearch module to incorporate Typesense functionality. In order to set the default page number upon page reload, I am utilising the searchFunction as shown below. However, the search request does not have the default page set, and instead, it is returning results from the first page upon reloading the page. Could anyone please look into it and help to fix the issue?

<ais-instant-search :search-client="searchClient"
        index-name="products_production"
        :search-function="searchFunction"
        >
</ais-instant-search>```
I hearchFunction(helper) {
helper.setPage(2).setQuery('cat')
if (helper.state.query) {
helper.search();
}
}```
Thank you.
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
02:16 PM
Could you try chaining all the helper calls in a single call like this:

helper.setPage(2).setQuery('cat').search()
Mehul
Photo of md5-375f12d6cdbb3bc6accdbd819d657bf3
Mehul
02:17 PM
Jason Its already tried.
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
02:18 PM
Then I’m not sure what’s happening. Might be better to ask the vue-instantsearch team by opening an issue in their repo, since this behavior is entirely before the search request reaches the Typesense adapter

But for your use-case of setting default search parameters, I’ve usually seen users use the configure widget: https://www.algolia.com/doc/api-reference/widgets/configure/vue/
Mehul
Photo of md5-375f12d6cdbb3bc6accdbd819d657bf3
Mehul
02:19 PM
Also set the default parameters at ais-configure. But still its not working. On reload everytime its fetching result for first page when page parameter is exist in URL.
02:20
Mehul
02:20 PM
If making any changes and save the code, that time its fetching correct data.