NuxtN
Nuxt2y ago
5 replies
Sh1be

watching routes not working?

Hello, I've been trying to get route watching the query params to work. https://router.vuejs.org/guide/advanced/composition-api.html#Accessing-the-Router-and-current-Route-inside-setup

I currently have a paginator component that modifies the route query params on click and I'm trying to watch for route query changes, but those seem to never occur. Following the docs, I got this code:
const route = useRoute();
const { data, error, refresh } = await useFetch("/api/items", {
  query: route.query
});

watch(() => route.query, () => refresh())

the refresh never happens.
is my approach to pagination wrong? how can I fix this?
The official Router for Vue.js
Was this page helpful?