Nuxt · Data fetching
NUXT0042Do not register write-like POST requests as async data
Finds write-like POST Nuxt async-data requests that can replay.
vite-doctor/nuxtfetchingwarnSuggestion
Why it happens
Nuxt async data can be replayed by refreshes, hydration, and watch sources. Write-like POST endpoints should not be registered as replayable data.
Fix
Move writes to $fetch() event handlers. Read-like POST query endpoints are ignored by default; configure readonlyPaths for read-only endpoints that look write-like.
Example
Move write-like POST work out of async data
Before
const { data } = await useFetch('/api/jobs/trigger', {
method: 'POST',
body,
})
After
async function triggerJob() {
await $fetch('/api/jobs/trigger', {
method: 'POST',
body,
})
}
Verify the fix
Run only this rule after editing so the report stays focused on the diagnostic you are closing:
pnpm nuxt doctor --rules nuxt/post-fetch-requires-readonly-marker