How to run dynamic Query in Tanstack Query?
0
I've been having a rough time understanding tanstack/query. I'm trying to fetch data using tanstack.
What I'm trying to get is store the data in my state, and then when I press the button, it will pass to my URL and then it will call the button.
This is my sample URL.
http://localhost:5000/api/result?from=8&end=10&year=23&college=CEIS&type=Students
This is my apicall
And this is my getResult
So what i'm trying to do is only get the data once the button is click, is that possible in tanstack/react-query 5?
3 Replies
unwilling-turquoise•2y ago
You can pass enabled argument to the useQuery and query will make the req only when payload is there
`
correct-apricotOP•2y ago
Sorry for late reply, am I gonna put in on my handle click?
unwilling-turquoise•2y ago
@adxvcasas no in resultQuery function
i usually convert it to customHook