The issue is that my view is not re-rendering nor is useFetch re-running when a pagination link is clicked. I suspect this is something to do with data reactivity in Nuxt - which is new to me.
I have this as my script.
<script setup lang="ts">
const route = useRoute();
const { data, status, error, refresh } = await useFetch("/api/search", {
query: useRoute().query,
});
const page_options = [10, 25, 50, 100];
</script>
The page renders correctly and processes the URL query params of q, per_page and page.
I have an array of links to navigate to the search URL with an updated page param.
<NuxtLink
:class="{
'p-2 border-2': true,
'bg-pink-800 text-white': index === Number(data.pagination.page),
}"
v-for="index in data.pagination.page_count"
:key="index"
:to="{
name: 'archive-search',
query: {
per_page: data.pagination.per_page,
page: index,
q: route.query.q,
},
}"
>
{{ index }}
</NuxtLink>
The URL updates but nothing is trigger either server side or client side. I suspect this is something to do with watching a value but how is this best done with url params?
Cheers.