NuxtN
Nuxt8mo ago
4 replies
enti

useFetch() and watch reactivity

I got a lack of reactivity on a useLazyFetch call:

// lazy fetching, but doesn't refresh automatically on its reactive sources from query part
const { refresh } = useLazyFetch(
  () => `/api/*********`,
  {
    query: {
      id: destination.id,    // ref
      dateDebut: startDate,  // computed
      dateFin: endDate,      // computed
      lang: locale,          // ref
    },
    immediate: false,
    // either I input watchers manually or not here, doesn't trigger when sources change
    watch: [destination.id, dateFin, locale],
  },
)

// but adding my own watchers work
watch(
  () => [destination.id.value, dateRange.value.end, locale.value],
  () => {
    refresh()
  },
)


How come my manual watch() works but the reactive sources in query won't trigger another fetching?
Was this page helpful?