Closed JanSmolko closed 4 years ago
const { get, data, loading, error } = useFetch(url, {
path: '/you/path/here',
cache: 'no-cache'
}, [])
The 1st argument of useFetch
if it's a string, will always be the URL or overwrite the global URL. That's why we have the path
option.
You can also do this if you have your global url setup in your Provider
const { get, data, loading, error } = useFetch({
path: '/you/path/here',
cache: 'no-cache'
}, [])
Going to close this, but feel free to comment more if you have any more questions or need more clarifications!
@alex-cory Sorry but I still dont get it. (To me) it seems like you answered to some other issue :/
When I call get()
again, It will not make another request.
Could you make a codesandbox showing me the problem please? :)
Oh, try cachePolicy: 'no-cache'
. If you don't want cache anywhere, you can set it in the Provider
Oh, try
cachePolicy: 'no-cache'
. If you don't want cache anywhere, you can set it in theProvider
https://codesandbox.io/s/stoic-meadow-yu6g9
OMG, thank you. thats it.
BTW: typescript had no problem with cache: 'no-cache'
and what is really working is cachePolicy: CachePolicies.NO_CACHE
@alex-cory Many Thanks!
I have similar question as in #161 and that is: How can I refetch data? (when I dont want to change anything in URL).
I thought that I can use it this way:
and then in some callback use
but I can call new request only with something like
Is there any way to do it without changing URL? Or am I missing something?