-
- {{ pending ? 'Loading' : count }}
-
-
-
-
-```
-
## `useFetch`
Within your pages, components and plugins you can use `useFetch` to universally fetch from any URL.
@@ -114,6 +60,66 @@ watch(posts, (newPosts) => {
```
+## `useAsyncData`
+
+Within your pages, components and plugins you can use `useAsyncData` to get access to data that resolves asynchronously.
+
+::alert
+You might be asking yourself: what is the difference between `useFetch` and `useAsyncData`?
+
+In brief, `useFetch` receives a URL and gets that data, whereas `useAsyncData` might have more complex logic. `useFetch(url)` is nearly equivalent to `useAsyncData(url, () => $fetch(url))` - it's developer experience sugar for the most common use case.
+::
+
+::ReadMore{link="/api/composables/use-async-data"}
+::
+
+### Example
+
+```ts [server/api/count.ts]
+let counter = 0
+export default () => {
+ counter++
+ return JSON.stringify(counter)
+}
+```
+
+```vue [app.vue]
+
+
+