-
Ran into a little edge case just now and was wondering if there was a solution for it: I have a request that looks like this
Now when I call Calling Is there any way to make |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
quick edit, even bound mutate doesn't work for this unless it comes from the same instance. For some more details, this is for pagination, so I want to add the cursor behind |
Beta Was this translation helpful? Give feedback.
-
I had the same problem for a while before remembering that const { data, mutate } = useSWR(['/api/some-route', someKey], fetcher);
mutate() With that being said, I agree, it would be awesome to be able to refresh data based on any of the keys passed to the array, from anywhere throughout an application. The behavior could possibly be modeled after Fastly's Surrogate Keys feature, which allows for purge caching based on any key in a list of keys passed in a header: https://docs.fastly.com/en/guides/getting-started-with-surrogate-keys |
Beta Was this translation helpful? Give feedback.
-
@team are we thinking on this feature request ? |
Beta Was this translation helpful? Give feedback.
-
@gmukul01 yeah, we've added support for this in v1.0. We still recommend you to use the hook-returned But if you still want to call it from somewhere else in the application, and you don't have access to some parts of the key, you can use this approach: Mutate Multiple Keys from RegEx. |
Beta Was this translation helpful? Give feedback.
@gmukul01 yeah, we've added support for this in v1.0. We still recommend you to use the hook-returned
mutate
as @botv mentioned.But if you still want to call it from somewhere else in the application, and you don't have access to some parts of the key, you can use this approach: Mutate Multiple Keys from RegEx.