-
-
Notifications
You must be signed in to change notification settings - Fork 35
post request - useQuery #179
Unanswered
JoeGaffney
asked this question in
Q&A
-
Hey,
Is there a way to make post requests use useQuery I have some endpoints that I need to send a body to fetch data.
Is this possible allready or is there some other way to signify a useQuery should be made instead of a useMutation?
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment
-
I made a wrapper function that converts useMutation to useQuery, allowing all parameters to be passed in a type-safe way. I also wrote a tutorial for it:
Usage looks like this:
const { data, isFetching } = useMutationQuery(
useTableServicePaginatedWithFilters,
{
page: pagination?.pageIndex + 1,
size: pagination?.pageSize,
requestBody: { ...filter }
}
)
Open to any ideas for improvement—hope it helps!
Let me know if you’d like to turn this into a shareable npm package or add types for even better DX.
Beta Was this translation helpful? Give feedback.
All reactions
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment