einargudnig / stupid-errors

I'll try to gather all of the stupid errors I have and how I fix them.
0 stars 0 forks source link

API typed response #2

Open einargudnig opened 6 days ago

einargudnig commented 6 days ago

Example: I get an array of organizations. Using custom hook. in the the response in the useQuery call create a interface used as a Generic<> that looks like this: organizations: Organization[].

Before we return we do this: const organizations: Organizations[] = data?.organizations || [];

we return this:

return {
 data: organizations,
 isLoading,
 isError,
 error
}