[Bug] useFetch with no cache policy caches on 500+
const { loading, get } = useFetch(
`${apiGateWayEndpoint}/api/v1/schdule`,
{
headers: {
'Content-Type': 'application/json',
},
redirect: 'follow',
cachePolicy: CachePolicies.NO_CACHE,
}
);
getData = async (id) => {
get(`?id=${id}`);
}
Is caching somehow and returning the previous ID's data on a 500+ error.
Could you make a codesandbox reproducing the bug please?
I think it's hard to prepare codesandbox for this but I do confirm that issue. The thing is you would have to prepare an API that will give the response on first time but will fail with the same request next time.
So if cachePolicy is set to default and you make a success response, and next time you change policy to no-cache AND make response failed, even then data is returning value from the previous cached request.
I think a workaround for @jakelheknight would be to add some query params to URL. But still, this is a bug in my opinion because no-cache should not return data from the previous responses. Now it returns even of new request is not made or failed