new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Nuxt · API · all subjects

utils

6 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

refreshNuxtData signature and parameters

refreshNuxtData is a function that refetches all or specific asyncData instances, including those from useAsyncData, useLazyAsyncData, useFetch, and useLazyFetch. The function signature is: export function refreshNuxtData (keys?: string | string[]). The keys parameter is optional and accepts a single string or an array of strings representing the keys used to fetch the data. When no keys are specified, all useAsyncData and useFetch keys are re-fetched.

refreshNuxtData return value

refreshNuxtData returns a promise that resolves when all or specific asyncData instances have been refreshed.

refreshNuxtData KeepAlive behavior

If a component is cached by KeepAlive and enters a deactivated state, the asyncData inside the component will still be refetched until the component is unmounted.

refreshNuxtData example - refresh all data

This example shows how to refresh all data being fetched using useAsyncData and useFetch in a Nuxt application: ```vue [app/pages/some-page.vue] <script setup lang="ts"> const refreshing = ref(false) async function refreshAll () { refreshing.value = true try { await refreshNuxtData() } finally { refreshing.value = false } } </script> <template> <div> <button :disabled="refreshing" @click="refreshAll" > Refetch All Data </button> </div> </template> ```

refreshNuxtData example - refresh specific data

This example shows how to refresh only data where the key matches specific values like 'count' and 'user': ```vue [app/pages/some-page.vue] <script setup lang="ts"> const refreshing = ref(false) async function refresh () { refreshing.value = true try { // you could also pass an array of keys to refresh multiple data await refreshNuxtData(['count', 'user']) } finally { refreshing.value = false } } </script> <template> <div v-if="refreshing"> Loading </div> <button @click="refresh"> Refresh </button> </template> ```

refreshNuxtData pitfall - use instance methods when available

If you have access to the asyncData instance, it is recommended to use its refresh or execute method as the preferred way to refetch the data instead of refreshNuxtData.

Give your agent this brain