My Mutation is stuck in loading state after successful request
Can't figure out what is going on here, made a POST request and it works fine.
Im trying to do a GET Request now using a mutation with no luck. Just stuck in loading state. The data comes back fine and the request is successful, the state is just wrong .

7 Replies
old-apricotOP•3y ago
Does
useMutation
just not work with GET requests?graceful-blue•3y ago
react query never cares about what kind of requests you make, it only cares about the Promise that gets retuned
old-apricotOP•3y ago
Okay cheers, must be something else going on then as my other requests work just not this GET one. Strange how they're all setup the same though. Most likely gonna be something super obvious. 😆
Yep sorted it, it was me.
This is what I was doing:
Needed to wrap in a useEffect:
graceful-blue•3y ago
If possible, make it part of an event handler rather than an effect
old-apricotOP•3y ago
Will do, thanks for the help
foreign-sapphire•3y ago
Can you show the code?
old-apricotOP•3y ago
Sure
Then used in component:
I have multiple login methods so rather than duping code i created a wrapper for mutation since i know the response for all login routes is the same