Skip to main content

# sdkBaseQuery()

    function sdkBaseQuery(config: {
      baseUrl?: string;
    }): BaseQueryFunction;

Base query function for RTK Query integration. Provides automatic error handling, authentication, and token refresh capabilities. Use this as the baseQuery for RTK Query API slices.

## Parameters​

### config​

Configuration options

#### baseUrl?​

`string`

Base URL for API requests

## Returns​

`BaseQueryFunction`

RTK Query base query function

## Example​

    import { createApi } from '@reduxjs/toolkit/query/react';

    const api = createApi({
      reducerPath: 'api',
      baseQuery: sdkBaseQuery({ baseUrl: 'https://api.example.com' }),
      endpoints: (builder) => ({
        getUser: builder.query({
          query: (id) => ({ url: `/users/${id}`, method: 'GET' })
        })
      })
    });