How to trigger data fetch on button click
Say I had 3 buttons in a UI a green one, a blue one, and a red one.
- When I click the green one, I want to fetch data for 'Bulbasaur' from the pokemon api.
- When I click the blue one, I want to fetch data for 'Squirtle' from the pokemon api.
- When I click the red one, I want to fetch data for 'Charmander' from the pokemon api.
I don't think it's possible to do this with useQuery, but using useMutation feels wrong since we're not mutating data.
How would you go about this?
- When I click the green one, I want to fetch data for 'Bulbasaur' from the pokemon api.
- When I click the blue one, I want to fetch data for 'Squirtle' from the pokemon api.
- When I click the red one, I want to fetch data for 'Charmander' from the pokemon api.
I don't think it's possible to do this with useQuery, but using useMutation feels wrong since we're not mutating data.
How would you go about this?