useFetch returns same value on multiple requests with same url
Reusing the same component that posts to a url and they all magicly return the same value as the first one that fetches.
What's the core of this problem?
Nuxt 3 doesn't know the difference between these requests and just returns the same response thinking its saving us valuable resources.
How do you fix it?
Use the key
property in UseFetchOptions
to set a unique indentifier for
this fetch. Use something unique to that component instance.
let {data: response, error: error, refresh: refresh, pending: pending} = await useFetch<PingResponse>('/api/ping', { body: {bodyElement: uniqueVariable.value}, key: uniqueVariable.value, method: "post" });
Written by lukeonuke.
Hobbyist computer programmer pursuing a informatics degree. Knows a thing or two about making computers beep and boop.