diff --git a/docs/content/2.guide/2.features/5.data-fetching.md b/docs/content/2.guide/2.features/5.data-fetching.md index cb83cc4d45..123f3d9ef2 100644 --- a/docs/content/2.guide/2.features/5.data-fetching.md +++ b/docs/content/2.guide/2.features/5.data-fetching.md @@ -173,6 +173,27 @@ const refresh = () => refreshNuxtData('count') ``` +## Options API support + +Nuxt 3 provides a way to perform `asyncData` fetching within the Options API. You must wrap your component definition within `defineNuxtComponent` for this to work. + +```vue + +``` + +::alert{type=warning} +Options API support for `asyncData` may well change before the stable release of Nuxt 3. +:: + ## Isomorphic `fetch` and `$fetch` When we call `fetch` in the browser, user headers like `cookie` will be directly sent to the API. But during server-side-rendering, since the `fetch` request takes place 'internally' within the server, it doesn't include the user's browser cookies, nor does it pass on cookies from the fetch response. diff --git a/test/basic.test.ts b/test/basic.test.ts index b3709b9359..f9574c562d 100644 --- a/test/basic.test.ts +++ b/test/basic.test.ts @@ -171,6 +171,14 @@ describe('head tags', () => { // }) }) +describe('legacy async data', () => { + it('should work with defineNuxtComponent', async () => { + const html = await $fetch('/legacy/async-data') + expect(html).toContain('