When to use "src/page/api/doStuff.ts" vs "src/server/api/routers/routerThatDoesStuff.ts"
I am trying to get data from a db AFTER I click a button. Correct me if i am wrong - to do this, you would use a useEffect that is dependent on a useState boolean, once true, inside the useEffect you do the fetching
My 1st screenshot is the page/api option
My 2nd is tRPC use query (the option i want to use).
I like the api route because I only call the api WHEN I CLICK THE BUTTON, but the second option (tRPC T3 way) I call it even before the button is clicked.
Just would like to know if I am doing the tRPC T3 way correctly or if there is a better way. Thanks
My 1st screenshot is the page/api option
My 2nd is tRPC use query (the option i want to use).
I like the api route because I only call the api WHEN I CLICK THE BUTTON, but the second option (tRPC T3 way) I call it even before the button is clicked.
Just would like to know if I am doing the tRPC T3 way correctly or if there is a better way. Thanks


