mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
docs(data-fetching): fix and improve example (#4824)
This commit is contained in:
parent
a862a67c80
commit
ecc8c0adb9
@ -118,13 +118,13 @@ watch(posts, (newPosts) => {
|
|||||||
|
|
||||||
Sometimes throughout the course of your user's page visit, you may need to refresh the data loaded from the API. This can happen if the user chooses to paginate, filter results, search, etc.
|
Sometimes throughout the course of your user's page visit, you may need to refresh the data loaded from the API. This can happen if the user chooses to paginate, filter results, search, etc.
|
||||||
|
|
||||||
You can make use of the `refresh()` method returned from the `useAsyncData()` composable to refresh the data with different query parameters:
|
You can make use of the `refresh()` method returned from the `useFetch()` composable to refresh the data with different query parameters:
|
||||||
|
|
||||||
```vue
|
```vue
|
||||||
<script setup>
|
<script setup>
|
||||||
const page = ref(1);
|
const page = ref(1);
|
||||||
|
|
||||||
const { data:users, loading, refresh, error } = await useFetch(() => `users?page=${page.value}&take=6`, { baseURL: config.API_BASE_URL }
|
const { data: users, pending, refresh, error } = await useFetch(() => `users?page=${page.value}&take=6`, { baseURL: config.API_BASE_URL }
|
||||||
);
|
);
|
||||||
|
|
||||||
function previous(){
|
function previous(){
|
||||||
|
Loading…
Reference in New Issue
Block a user