Refactor RTK Query Endpoints to use baseQuery to Remove Code Duplication

Share this video with your friends

Send Tweet

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.