We can reduce code duplication using a baseQuery
from RTK Query. We do this by moving duplicate code into a baseQuery
function and writing query
functions instead of queryFn
. The return value of those query
functions will be passed on as first argument into the baseQuery
.