From the course: Learning Nuxt.js
Unlock the full course today
Join today to access over 24,400 courses taught by industry experts.
Data fetching in Nuxt
- [Instructor] In Nuxt, you can fetch data from external sources into your applications, using a concept called data fetching. It involves you sending HTTP requests to an API source using one of the Nuxt data fetching methods and a data fetching module, like the HTTP or Axios module. Nuxt has two hooks for loading data asynchronously. The asyncData hook and the fetch hook. Now, each of them has its own use case, and in the next lessons we'll cover what each hook is and how it works. First, we have the asyncData hook. I'll be using the Nuxt life circle diagram to explain how the asyncData hook works under the hood. The asyncData hook is only available on page level components and it is called before loading the page. Therefore, there is no visible loading placeholder during client side rendering. Instead, the hook will block routes navigation until it fully loads the page. Or, until the page displays an error. The…