Skip to content

Commit

Permalink
docs: asyncData merging type (#1254)
Browse files Browse the repository at this point in the history
This removes ambiguity on how asyncData merges with component data i.e. only a shallow merge is done. Users should not expect a deep merge.
  • Loading branch information
kamikazechaser authored and ImgBotApp committed Jan 10, 2023
1 parent dc0f81d commit 5e31f2a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion content/en/guides/features/data-fetching.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ The navigation to the same page will not call `fetch` if last `fetch` call w

Unlike `fetch`, the promise returned by the `asyncData` hook is resolved _during route transition_. This means that no "loading placeholder" is visible during client-side transitions (although the [loading bar](https://nuxtjs.org/guides/features/loading/) can be used to indicate a loading state to the user). Nuxt will instead wait for the `asyncData` hook to be finished before navigating to the next page or display the [error page](/docs/2.x/directory-structure/layouts#error-page)).

This hook can only be used for page-level components. Unlike `fetch`, `asyncData` cannot access the component instance (`this`). Instead, it receives [the context](/docs/2.x/concepts/context-helpers) as its argument. You can use it to fetch some data and Nuxt.js will automatically merge the returned object with the component data.
This hook can only be used for page-level components. Unlike `fetch`, `asyncData` cannot access the component instance (`this`). Instead, it receives [the context](/docs/2.x/concepts/context-helpers) as its argument. You can use it to fetch some data and Nuxt.js will automatically shallow merge the returned object with the component data.

In the upcoming examples, we are using [@nuxt/http](https://http.nuxtjs.org/) which we recommend for fetching data from an API.

Expand Down

0 comments on commit 5e31f2a

Please sign in to comment.