Skip to content
Discussion options

You must be logged in to vote

as discussed on Discord, queryClient.fetchQuery is what you'd want. It will resolve the promise to data from the cache, and re-fetch if it's stale:

const { mutate } = useMutation(
  async (variables) => {
     const data = await queryClient.fetchQuery(key);
     return axios.post(...)
  }
)

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
1 reply
@aminick
Comment options

Comment options

You must be logged in to vote
3 replies
@motss
Comment options

@TkDodo
Comment options

@motss
Comment options

Answer selected by aminick
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants