seGetPostQuery(id, { skip: !id })  
      
      return <div>...</div>  
    }  
    

While you might be able to convince yourself that the query won't be called
unless the ` id ` arg is a ` number ` at the time, TypeScript won't be
convinced so easily.

RTK Query provides a ` skipToken ` export which can be used as an alternative
to the ` skip ` option in order to skip queries, while remaining type-safe.
When ` skipToken ` is passed as the query argument to ` useQuery ` , `
useQueryState ` or ` useQuerySubscription ` , it provides the same effect as
setting ` skip: true ` in the query options, while also being a valid argument
in scenarios where the ` arg ` might be undefined otherwise.

Using skipToken in a component

    
    
    import { skipToken } from '@reduxjs/toolkit/query/react'  
    import { useGetPostQuery } from './api'  
      
    function MaybePost({ id }: { id?: number }) {  
      // When `id` is nullish, we will still skip the query.  
      // TypeScript is also happy that the query will only ever be called with a `number` now  
      const { data } = useGetPostQuery(id ?? skipToken)  
      
      return <div>...</div>  
    }  
    

##  Type safe error handling  ​

When an error is gracefully provided from a [ ` base query ` ](/rtk-
query/api/createApi#baseQuery) , RTK query will provide the error directly. If
an unexpected error is thrown by user code rather than a handled error, that
error will be transformed into a ` SerializedError ` shape. Users should make
sure that they are checking which kind of error they are dealing with before
attempting to access its properties. This can be done in a type safe manner
either by using a type guard, e.g. by checking for [ discriminated properties
](https://www.typescriptlang.org/docs/handbook/2/narrowing.html#the-in-
operator-narrowing) , or using a [ type predicate
](https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-
predicates) .

When using [ ` fetchBaseQuery ` ](/rtk-query/api/fetchBaseQuery) , as your base query, errors will be of type ` FetchBaseQueryError | SerializedError ` . The specific shapes of those types can be seen below. 

  * TypeScript 
  * JavaScript 

FetchBaseQueryError type

    
    
    export type FetchBaseQueryError =  
      | {  
          /**  
           * * `number`:  
           *   HTTP status code  
           */  
          status: number  
          data: unknown  
        }  
      | {  
          /**  
           * * `"FETCH_ERROR"`:  
           *   An error that occurred during execution of `fetch` or the `fetchFn` callback option  
           **/  
          status: 'FETCH_ERROR'  
          data?: undefined  
          error: string  
        }  
      | {  
          /**  
           * * `"PARSING_ERROR"`:  
           *   An error happened during parsing.  
           *   Most likely a non-JSON-response was returned with the default `responseHandler` "JSON",  
           *   or an error occurred while executing a custom `responseHandler`.  
           **/  
          status: 'PARSING_ERROR'  
          originalStatus: number  
          data: string  
          error: string  
        }  
      | {  
          /**  
           * * `"CUSTOM_ERROR"`:  
           *   A custom error type that you can return from your `queryFn` where another error might not make sense.  
           **/  
          status: 'CUSTOM_ERROR'  
          data?: unknown  
          error: string  
        }  
    

FetchBaseQueryError type

    
    
    export {}  
    

  * TypeScript 
  * JavaScript 

SerializedError type

    
    
    export interface SerializedError {  
      name?: string  
      message?: string  
      stack?: string  
      code?: string  
    }  
    

SerializedError type

    
    
    export {}  
    

###  Error result example  ​

When using ` fetchBaseQuery ` , the ` error ` property returned from a hook will have the type ` FetchBaseQueryError | SerializedError | undefined ` . If an erro