From 14464b566e0cce7a78f9664a7cd4366564bb69f9 Mon Sep 17 00:00:00 2001 From: Lucas Viana Date: Sun, 27 Oct 2024 23:14:47 -0300 Subject: [PATCH] Introduce the `useAsyncData()` sample code (with API endpoint) --- pages/experiments/data-fetching/nuxt/index.vue | 13 +++++++++++-- server/api/data-fetching/nuxt/use-lazy-fetch.get.ts | 3 ++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/pages/experiments/data-fetching/nuxt/index.vue b/pages/experiments/data-fetching/nuxt/index.vue index 293346a..a5c5369 100644 --- a/pages/experiments/data-fetching/nuxt/index.vue +++ b/pages/experiments/data-fetching/nuxt/index.vue @@ -29,7 +29,10 @@

useFetch() = {{ useLazyFetchResponse.data.value?.value ?? 0 }}

useAsyncData()

- WIP +

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

+ +

useAsyncData() = {{ useAsyncDataResponse.data.value }}

+

Server-sent Events

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

@@ -50,7 +53,7 @@