mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-29 00:52:01 +00:00
90784f79d7
* docs: implement new website theme * chore: rename dirs * chore: update build * lint fix * chore: update deps * fix: include node_modules in esbuild step * chore: update deps * Update .gitignore * chore: update theme version * up * up * fix: use svg for illustration * chore: update to 0.0.12 * chore: force parse5 resolution * stay with build * feat: always display first home section * Update yarn.lock * chore: update theme * fix lint * docs: update home title * chore: update website theme version * Update docs/content/0.index.md Co-authored-by: pooya parsa <pyapar@gmail.com> * Update docs/content/0.index.md Co-authored-by: pooya parsa <pyapar@gmail.com> * up * chore: bump theme version * up * chore: up * up up and up * chore: generate * fix: boolean value * feat: new images * update again * chore: up * ouep * chore: up Co-authored-by: Daniel Roe <daniel@roe.dev> Co-authored-by: Clément Ollivier <clement.o2p@gmail.com> Co-authored-by: pooya parsa <pyapar@gmail.com>
1.6 KiB
1.6 KiB
title | description |
---|---|
refreshNuxtData | refreshNuxtData refetches all data from the server and updates the page. |
refreshNuxtData
refreshNuxtData
re-fetches all data from the server and updates the page as well as invalidates the cache of useAsyncData
, useLazyAsyncData
, useFetch
and useLazyFetch
.
Type
refreshNuxtData(keys?: string | string[])
Parameters:
-
keys
:Type:
String | String[]
refreshNuxtData
accepts a single or an array of strings askeys
that are used to fetch the data. This parameter is optional. AlluseAsyncData
anduseFetch
are re-fetched when nokeys
are specified.
Examples
Refresh All data
This example below refreshes all data being fetched using useAsyncData
and useFetch
on the current page.
<template>
<div>
<button :disabled="refreshing" @click="refreshAll">
Refetch All Data
</button>
</div>
</template>
<script setup>
const refreshing = ref(false)
const refreshAll = async () => {
refreshing.value = true
try {
await refreshNuxtData()
} finally {
refreshing.value = false
}
}
</script>
Refresh Specific Data
This example below refreshes only data where the key matches to count
.
<template>
<div>
{{ pending ? 'Loading' : count }}
</div>
<button @click="refresh">Refresh</button>
</template>
<script setup>
const { pending, data: count } = useLazyAsyncData('count', () => $fetch('/api/count'))
const refresh = () => refreshNuxtData('count')
</script>
::ReadMore{link="/docs/getting-started/data-fetching"} ::