title: Redux Toolkit RTK Query sending query parameters
body: <p>How do you pass query parameters to the api using Redux Toolkit RTK Query?</p>
  <pre><code>import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react';
  
  const baseUrl = 'xxxxxxx';
  
  export const postsApi = createApi({
    reducerPath: 'posts',
    baseQuery: fetchBaseQuery({ baseUrl }),
    endpoints: (builder) =&gt; ({
      getPostsByYear: builder.query({
        query: (start, end) =&gt; { // Why is 'end' always undefined???
          return {
            url: 'posts/',
            params: { start, end },
          };
        },
      }),
      getPosts: builder.query({
        query: () =&gt; 'posts/',
      }),
  
      getPostByID: builder.query({
        query: (name) =&gt; `posts/${name}`,
      }),
    }),
  });
  
  export const { useGetPostsQuery, useGetPostsByYearQuery, useGetPostByIDQuery } = postsApi;
  </code></pre>
  <p>When trying to pass parameters from the component only the <code>start</code> value seems to be recognised. <code>year</code> is updated by a select element within the <code>&lt;PostOptions/&gt;</code> component. It's using the <code>useState</code> hook. The value updates correctly and <code>useGetPostsByYearQuery</code> is called but the <code>end</code> parameter is always undefined. So, it seems I'm not defining the api endpoint correctly. Any advise? All I want it to do is send a request in the form <code>http://xxx/posts?start=start&amp;end=end</code>.</p>
  <p>I've even tried hard-coding a string value for the <code>end</code> parameter, e.g. <code>useGetPostsByYearQuery(year, '2019')</code>, but it still appears as <code>undefined</code> withing the api callback so I'm missing something more fundamental.</p>
  <pre><code>const Post = () =&gt; {
   
    const year = useSelector((state) =&gt; state.postOptions.year);
    const yearPlusOne = parseInt(year, 10) + 1;
    const { data, error, isLoading } = useGetPostsByYearQuery(year, yearPlusOne);
  
    return (
      &lt;SafeAreaView style={styles.container}&gt;
        &lt;View style={styles.content}&gt;
          &lt;PostHeading /&gt;
          &lt;PostOptions&gt;&lt;/PostOptions&gt;
        &lt;/View&gt;
      &lt;/SafeAreaView&gt;
    );
  };
  
  export default Post;
  </code></pre>