The definition for a query in RTK Query is query<ResultType, QueryArg>
. All of this is fine for queries where I actually need to send parameters to the API. However, I have some endpoints which don't require anything to be sent (something like getAllX). What can I pass as QueryArg here in the template? It won't accept having one argument.
So far I've used types like undefined
and null
to denote that nothing needs to be sent, but it looks ugly when you use the hook: const {...} = useGetXQuery(undefined)
, and I'm pretty sure there has to be a better way, but scouring the internet yielded no results.
{}
? It's way cleaner – Hackneyedvoid
type. – Francisfrancisca