Is it possible to revalidate the first call from useSWRInfinite? #2226
Unanswered
philmetzger
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am using useSWRInfinite like so:
where page X changes for the next pages etc.
Now I have a list of "posts". If a user created a new post, i would like to calls the first api endpoint, e.g.
'/api/posts?page=1'
to get the new post and put it in the list.I tried using mutate from
import { mutate } from 'swr'
and then calling it like this after a post is created:mutate('/api/posts?page=1')
But nothing seems to happen. I expect the new post to popup in the list.
How could I achieve this?
I also cant use
mutate
from useSWRInfinite because the data from the api is different to the data from the create endpoint. (i could reformat the data, but would rather not)Beta Was this translation helpful? Give feedback.
All reactions