From 5d2ac285763ee9125baaf840e6cba92b647fe390 Mon Sep 17 00:00:00 2001 From: Victor Akintunde <32616421+akintoluvic@users.noreply.github.com> Date: Mon, 18 Dec 2023 19:37:51 +0100 Subject: [PATCH] docs: update return for `useFetch` and `useAsyncData` #24407 (#24775) --- docs/1.getting-started/6.data-fetching.md | 20 ++++++++++++++++++++ docs/3.api/2.composables/use-async-data.md | 4 ++++ docs/3.api/2.composables/use-fetch.md | 4 ++++ 3 files changed, 28 insertions(+) diff --git a/docs/1.getting-started/6.data-fetching.md b/docs/1.getting-started/6.data-fetching.md index d283ecc2db..47cb56f529 100644 --- a/docs/1.getting-started/6.data-fetching.md +++ b/docs/1.getting-started/6.data-fetching.md @@ -143,6 +143,26 @@ const { data: discounts, pending } = await useAsyncData('cart-discount', async ( Read more about `useAsyncData`. :: +## Return Values + +`useFetch` and `useAsyncData` have the same return values listed below. + +- `data`: the result of the asynchronous function that is passed in. +- `pending`: a boolean indicating whether the data is still being fetched. +- `refresh`/`execute`: a function that can be used to refresh the data returned by the `handler` function. +- `error`: an error object if the data fetching failed. +- `status`: a string indicating the status of the data request (`"idle"`, `"pending"`, `"success"`, `"error"`). + +::callout +`data`, `pending`, `error` and `status` are Vue refs accessible with `.value` in ` ``` +::callout +`data`, `pending`, `status` and `error` are Vue refs and they should be accessed with `.value` when used within the ` ``` +::callout +`data`, `pending`, `status` and `error` are Vue refs and they should be accessed with `.value` when used within the `