Search code examples
vue.jsnuxt.jsvuejs3nuxt3.js

How can I disable the cache after receiving an error response from useFetch in Nuxt 3.8


If I run useFetch and receive 404 500...
After changing the page and returning to the original page, useFetch will not request again, the same information will remain.
But if I refresh the page, useFetch works correctly.

const load = async () => {
  const { data, error, status } = await useFetch('http://server.test/api/test', {
    method: 'GET',
  });

  if (error.value) {
    console.log('error', error.value);
  }
};

load();

How do I disable this cache?


Solution

  • It is an error from the framework. Fix in Nuxt 3.8.1

    https://github.com/nuxt/nuxt/pull/23889
    https://github.com/nuxt/nuxt/pull/23797