vue-instantsearch
vue-instantsearch copied to clipboard
Double query with either ais-hits or ais-pagination
Bug 🐞
Appreciate this has somewhat been discussed previously, however, that was where ais-hits was nested inside ais-state-results, here this is not using ais-state-results though maybe the issue is the same? This also occurs just with ais-pagination.
What is the current behavior?
Multiple algolia queries are made on page load where I include ais-hits or/and ais-pagination widgets
For some context I am using ais-configure with a query param as this is for a search results page. This is not using the search box widget.
Make a sandbox with the current behavior
I can't reproducible sandbox with duplicate requests as setup is different, php loading vue via templates. I have made a reproducible repo here with just an index.html and js file in parcel: https://github.com/joepagan/vue-algolia-test
What is the expected behavior?
1 request not 2 on page load
Does this happen only in specific situations?
page load
What is the proposed solution?
1 request
What is the version you are using?
"algoliasearch": "4.9.1",
"vue": "2.6.12",
"vue-instantsearch": "3.7.0"
The joepagan/vue-algolia-test repo doesn't seem too representative of your issue, or is it?
When a widget is mounted, it triggers a new network request. Could it be that in your real environment, you're adding one widget after the other?
Hi @francoischalifour thanks for getting back.
The joepagan/vue-algolia-test repo doesn't seem too representative of your issue, or is it?
I have just loaded up my test repo again and on page load it is definitely making 2 requests:
request 1: {"requests":[{"indexName":"index_name","params":"hitsPerPage=10&query=apple&facets=%5B%5D&tagFilters="}]}
request 2: {"requests":[{"indexName":"index_name","params":"hitsPerPage=10&query=apple&highlightPreTag=__ais-highlight__&highlightPostTag=__%2Fais-highlight__&page=0&facets=%5B%5D&tagFilters="}]}
When a widget is mounted, it triggers a new network request. Could it be that in your real environment, you're adding one widget after the other?
I am using multiple widgets here which you can see in the index.html: ais-configure, ais-stats, ais-hits, ais-pagination, is that just how it works? Sorry if this is a stupid question though it seems like this should only need 1 request?
I can see this same behavior on multiple environments at the moment.
Hello @joepagan I'm sorry but I can't get this repo to work.
FYI, I'm using [email protected]. Can you help me run it?
Of course I'll help, as I hope you can help me lol! Forgive me if you already have done this, but did you update the app & key data attributes to real app & key values? and the same with the index-name attribute to a working index?
Hi! This issue has been opened without reply for a while. I'll close it now, but feel free to reply to our initial questions, and we'll gladly reopen if the original issue isn't solved yet.
Have a nice day!