Nuxt, routing without initial query parameters
See original GitHub issueBug 🐞 Hey Algolia
We have a solution using algolia and vue instantsearch in nuxt. All the features wors as intended and everything is good. except the routing feature in algolia.
When we load a page using the queries in algolia it has some initial parameters even thoung nothing is set in the filter yet. is there any solution to change the initial url when no filter params is set
from: /alle-produkter/?AHjort%20Products%20da-DK%5BsortBy%5D=AHjort%20Products%20da-DK to: /alle-produkter/
This is the router code:
export function nuxtRouter(vueRouter: any) {
return {
read() {
return vueRouter.currentRoute.query;
},
write(routeState: any) {
vueRouter.push({
query: routeState
});
},
createURL(routeState: any) {
return vueRouter.resolve({
query: routeState
}).href;
},
onUpdate(cb: any) {
if (typeof window === "undefined") return;
(this as any)._onPopState = (event: any) => {
const routeState = event.state;
if (!routeState) {
cb(this.read());
} else {
cb(routeState);
}
};
window.addEventListener("popstate", (this as any)._onPopState);
},
dispose() {
if (typeof window === "undefined") { return; }
window.removeEventListener("popstate", (this as any)._onPopState);
},
};
}
And when i use the route back (popstate) i have to go back 3 times to go back the the previous page.
Tell me if you need more from me to go more in depth with this issue.
Issue Analytics
- State:
- Created 3 years ago
- Comments:25 (9 by maintainers)
Top Results From Across the Web
How to get route url params in a page in Nuxt2 and 3?
To read params from URL you should use this way in Nuxt: this.$route.query.
Read more >File System Routing - Nuxt
File system routing. Nuxt automatically generates the vue-router configuration based on your file tree of Vue files inside the pages directory.
Read more >How to Use URL Query Params in Nuxt 3 | by Cody Bontecou
With access to our route, we can check the query variable (what's after the = in streamer= ) using route.query.streamer . Easy! I...
Read more >Accessing Route Parameters in Nuxt 3 - Server Side Up
Accessing route parameters is an essential for your Nuxt 3 app. Route parameters are the dynamic pieces of your URL that determine what ......
Read more >Routing - NuxtJS
Validate Route Params ... Nuxt.js lets you define a validator method inside your dynamic route component. ... If the validate method does not...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you @Haroenv it all works now! THANK YOU!!
@Haroenv i can see its because my price filter is programatically setting som values. so everything works now thanks a lot! do you have any codesandbox with a range slider using vue-slider?