mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-18 09:25:54 +00:00
docs: update count example (#743)
This commit is contained in:
parent
3bf6bb10fd
commit
d09a5531f2
@ -24,18 +24,21 @@ Under the hood, `defer: false` uses `<Suspense>` to block the loading of the rou
|
||||
|
||||
### Example
|
||||
|
||||
```js [server/api/index.ts]
|
||||
```js [server/api/count.ts]
|
||||
let counter = 0
|
||||
export default () => ++counter
|
||||
export default () => {
|
||||
counter++
|
||||
return JSON.stringify(counter)
|
||||
}
|
||||
```
|
||||
|
||||
```vue [pages/index.vue]
|
||||
<script setup>
|
||||
const { data } = await useAsyncData('time', () => $fetch('/api/count'))
|
||||
const { data } = await useAsyncData('count', () => $fetch('/api/count'))
|
||||
</script>
|
||||
|
||||
<template>
|
||||
Page visits: {{ data.count }}
|
||||
Page visits: {{ data }}
|
||||
</template>
|
||||
```
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user