Skip to content

Commit

Permalink
fix issue when refreshing /demo/fetch-data page
Browse files Browse the repository at this point in the history
  • Loading branch information
dncsvr committed Aug 8, 2024
1 parent 5e14668 commit 612229b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .theme/pages/demo/fetching-data.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const repository = ref([]);
const contributors = ref();
// Fetch Once - Server or Client
const { data: organization } = await useAsyncData(() => getOrganization(organizationName));
const { data: organization } = await useAsyncData("organization", async() => await getOrganization(organizationName));
// Fetch Once - Only Client
onBeforeMount(async() => repository.value = await getRepository(repositoryFullName));
Expand Down
10 changes: 10 additions & 0 deletions network.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ We do the one-time fetch operations on the server side and bring them to the
client side by making the server side of `useAsyncData` true. Use this method if
this data is not expected to change frequently.

> :info:
>
> We experienced issues when using `ContentQuery` and `useAsyncData` within
> script setup, we solved the issue by using _async_ and _await_ keywords when
>invoking async function in `useAsyncData()`
>
> ```javascript
> await useAsyncData(async () => await ...);
> ```
### Fetch Once - Only Client
We use `onMounted`, `onBeforeMount` etc. methods for the fetch operations
Expand Down

0 comments on commit 612229b

Please sign in to comment.