Nuxt offers three different methods to fetch data:
$fetch()useFetch()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
Streaming data from the server using EventSource in the API routes:
Items:
(Empty)