T
TanStack3y ago
xenophobic-harlequin

how to get cached response?

im trying to get cached response data with queryCache.find(getKey('key')) but it returns a query how can i return an exact data which comes in response ?
6 Replies
xenophobic-harlequin
xenophobic-harlequinOP3y ago
i can do queryCache.find(getKey('key')).state.data but if there any other way?
foreign-sapphire
foreign-sapphire3y ago
please try to ask better questions. What problem are you trying to solve? https://tkdodo.eu/blog/how-can-i
How can I ... ?
Asking the right questions is a form of art that needs to be mastered.
xenophobic-harlequin
xenophobic-harlequinOP3y ago
tryin to get the exact response data in cache by key not a query
foreign-sapphire
foreign-sapphire3y ago
but what for? The answer is probably queryClient.getQueryData, but unless you describe your use-case, it might be that you're looking at it the wrong way ...
xenophobic-harlequin
xenophobic-harlequinOP3y ago
1. doing the request with different page number 2. store all pages in the cache 3. queryCache.findAll(key) getting all pages with that key 4. loop through all pages and push all items into single array 5. return the array and render it this is how my component works with pagination on page but to get the data i need to dive deep into query.state.data wondering can i just get the exact response data
foreign-sapphire
foreign-sapphire3y ago
you might want an infinite query, because it can do all of that by itself

Did you find this page helpful?