Data Fetching in Nuxt

Nuxt offers three different methods to fetch data:

  1. $fetch()
  2. useFetch()
  3. useAsyncData()

The following experiments detail each one of these methods (you may need to use the DevTools to understand it better).

$fetch()

Fetches data both on server and client side (check server console):

$fetch() = 1

useFetch()

Fetches data both only on server (unless client-side navigation happens):

status = success

useFetch() = 2

The data can be lazy-loaded not to block the page rendering.

status = success

useFetch() = 2

useAsyncData()

Allows loading data asynchronously and passing it from the server to the client:

useAsyncData() = 3

Server-sent Events

Streaming data from the server using EventSource in the API routes:

Items:

(Empty)