-
Notifications
You must be signed in to change notification settings - Fork 36
Open
Description
Calls to the TYPO3 API are executed twice when the query parameter is changed.
When changing the query by using, for example,
await router.push({ query: { ...route.query, page: String(target) } })
/downloads?page=1 >> to >> /downloads?page=2 - etc...
The first execution occurs when the ‘pageCacheKey’ key changes, which in my case is fullPath
‘/downloads?page=1’
- the ‘pageCacheKey’ key is relative, which means that changing it automatically executes 'useAsyncData'
// node_modules/@t3headless/nuxt-typo3/dist/runtime/composables/useT3Page.js
const { data, execute: getAsyncPage, error } = useAsyncData(
useLegacyAsyncDataPageKey ? pageCacheKey.value : pageCacheKey,
() => {
console.log('useAsyncData new key:', route.fullPath); // /downloads?page=2
return getPage(route.fullPath)
},
{
immediate: false
}
);
The second execution occurs later during the watcher that tracks route.query and, when it changes, executes ‘useAsyncData’ again manually via ‘getPageData() -> getAsyncPage()’.
// node_modules/@t3headless/nuxt-typo3/dist/runtime/composables/useT3Page.js
watch(() => route.query, () =>
{
console.log('execute useAsyncData > new query', route.fullPath); // /downloads?page=2
getPageData()
});
As a result, after changing the query parameter from ‘page=1’ to ‘page=2’,
the API query is executed twice.
Question: What was or is the purpose of watcher on route.query?
Versions:
"nuxt": "4.1.0"
"@t3headless/nuxt-typo3": "2.3.0"
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels