Changing content in dev mode triggers execute-function of useAsyncData?
Environment
- Operating System:
Darwin - Node Version:
v22.14.0 - Nuxt Version:
3.17.4 - CLI Version:
3.25.1 - Nitro Version:
2.11.12 - Package Manager:
[email protected] - Builder:
- - User Config:
modules,devtools,css,routeRules,future,compatibilityDate,nitro,eslint - Runtime Modules:
@nuxt/[email protected],@nuxt/[email protected],@nuxt/[email protected],@nuxt/[email protected],@vueuse/[email protected],[email protected] - Build Modules:
-
Version
3.5.1
Reproduction
https://github.com/ahoiroman/content-reproducer
Description
If content is edited and saved, the execute function is being called. In the reproducer you can see that, as the toast of the newsletter subscription is shown.
https://github.com/user-attachments/assets/d45dac53-e9fe-4cc1-b1ea-2455df625d33
Additional context
No response
Logs
This is expected behavior, When you change the content in dev mode, the module asks Nuxt to reload the page data. By this Nuxt will recall data fetches. I suggest not writing logics like toast, etc, in the sync-data function.
But when I am in a dashboard-like scenario, delete-procedures of resources will be triggered, even if I do not want that.
I would not call this expected behavior…? Especially not, when the data fetches are flagged with immediate: false
Delete procedures and other api calls should be called at the top level. Delete should happen in an event and inside a function. Nuxt will only refresh top-level asyncs.
Please provide an example of the delete procedures.
useAsyncData should not be called in a function, and I think we agree that I only should call the execute() function. And that's what I am doing. And the example does the same: https://github.com/ahoiroman/content-reproducer/blob/main/app/components/AppFooter.vue#L54
And if you stick to the example that is provided: This is a newsletter subscription, which is flagged with immediate: false. I would not expect a content change to perform POST, PUT, DELETE or PATCH calls or anything that is flagged with immediate: false.
To my understanding, posting/deleting/putting/patching data this way is totally fine. This is also shown by Alex Lichter (https://www.youtube.com/watch?v=njsGVmcWviY&t=213s), too.
To my understanding, posting/deleting/putting/patching data this way is totally fine. This is also shown by Alex Lichter (youtube.com/watch?v=njsGVmcWviY&t=213s), too.
Watch what Alex suggests at the end of video. https://youtu.be/njsGVmcWviY?si=d8OprpUSkuMptmk0&t=588
I would not expect a content change to perform POST, PUT, DELETE or PATCH calls or anything that is flagged with immediate: false.
This is more like an issue with Nuxt itself than Nuxt Content module. Nuxt Content just asks Nuxt to refetch the data. If data is not fetched yet, Nuxt should respect that.
Also I highly recommend to not use Nuxt Async Composables for non 'GET` requests.
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.
This issue was closed because it has been stalled for 30 days with no activity.