useLazyFetch with useRoute query not work
See original GitHub issueEnvironment
useLazyFetch
Reproduction
useLazyFetch
Describe the bug
there is a Pagination component
<template>
<div class="tw-flex tw-flex-wrap tw-justify-between">
<div class="tw-flex tw-items-center">
<div class="tw-flex">
<nuxt-link v-for="(page, index) in pageCount" :key="index"
:class="[activePageNumber == page ? 'tw-bg-default-600 tw-text-white': 'tw-bg-transparent']"
:to="`${link}?page=${page}`"
class="tw-py-2 tw-px-3 tw-mr-2 tw-rounded tw-cursor-pointer tw-inline-block tw-h-8 tw-text-center"
>{{ page }}
</nuxt-link>
</div>
</div>
</div>
</template>
<script lang="ts" setup>
import { useRoute } from '#app';
import { computed } from '#imports';
const props = defineProps({
params: {
type: Object,
required: true
}
});
const route = useRoute();
const link = computed(() => {
return route.path;
});
const pageCount = computed(() => {
return Math.ceil(props.params.total / props.params.take);
});
const activePageNumber = computed(() => {
return route.query.page ?? 1;
});
</script>
My page
const route = useRoute();
const params = reactive({
skip: 0,
take: 4
});
const meta = reactive({
skip: 0,
take: 4,
total: 0
});
if (route.query?.page) params.skip = route.query?.page;
const {
pending,
data:excursions
} =
repositoryService.repository.getExcursionsByPaginate(params);
After clicking on pagination links, substitution in useLazyFetch route.query.page does not work
Additional context
No response
Logs
No response
Issue Analytics
- State:
- Created a year ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
useRoute · Nuxt Composables
The useRoute composable returns the current route and must be called in a setup function, plugin, or route middleware. Within the template of...
Read more >Route query is undefined when using useRoute() in setup() for ...
However, this is not true for strings, which is the reason the searchQuery string is undefined in the log, while the route object...
Read more >[Solution] NextJS Router Query Not Working in useEffect
A simple example would be something like this: Notice the data is undefined on the console, but it is rendered on the DOM....
Read more >Nuxt 3 公式ドキュメント 日本語訳 - Zenn
そして、 npm run <command> または yarn <command> を使って各コマンドを実行する ... The requested module 'sample-library' is a CommonJS module, which may not ...
Read more >Data Fetching - 《Nuxt 3 beta Documentation》 - 书栈网
Nuxt provides useFetch , useLazyFetch , useAsyncData and useLazyAsyncData ... In other words, the async function does not block navigation.
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
useLazyFetch
seems not regenating a key for each request, all myuseLazyFetch
calls returns the same response of the first call.I have something related, when I use the route.name in a computed variable OR use the route(.name) in a watch function it doesn’t get triggered after navigating.
When I output the $route.name in the template tag, this does get updated after navigating.