useQuery() if you are fetching data from the server. ( irrespective of methods GET/ POST )
useMutation() if you are modifying data on the server.
Back story 💭
I am under a misconception, that useQuery is only for GET requests and all other requests ( POST, PUT, DELETE ) are handled by useMutation.
But as mentioned in the above tweet I got the below case.
Need to fetch data using a POST request.
Initially, I invoked useMutation on the mount with useEffect. ( To get the Data )
and never used thereafter in the code to mutate any data.
This looked like a useQuery material!
Can we use useQuery for POST requests, I didn't find a direct blog/ article but on reading through the DOCS found that we can use useQuery for POST requests as well and got a much neater understanding on what useQuery and useMutation are meant for.
If you got a similar use case go ahead and use useQuery ✅