NuxtN
Nuxtβ€’17mo ago
abd

useFetch && $fetch

hello,

I have a page component with a date picker. when the page component loads it is fetching data for the default date today() for the user using usefetch

The user can then select a different date to select data for that date.

I get this warning in the console
Component is already mounted, please use $fetch instead.


This is my component code

  const fetchContent = async (newDateRange) => {
    isLoading.value = true
    const { data } = await useFetch("/api/content", {
      method: "POST",
      body: JSON.stringify({
        startDate: newDateRange.start,
        endDate: newDateRange.end,
      }),
    })

    presentContent.value = data.value
    isLoading.value = false
  }


What is the correct pattern to use?
Was this page helpful?