title: how do I perform conditial query params in axios?
body: <p>I am trying to build a conditional dynamic react component where makes an API call based on the user interaction, but if the user types something in the search bar. I want to add <code>search=</code> param the otherwise use <code>/list</code> endpoint without query params. I am using currently Axios , and I would like to know some approach to do the following</p>
  <pre><code>const FeedsList = () =&gt; {
      const [feed, setFeed] = useState([]);
      const [currentPageUrl, setCurrentPageUrl] = useState(&quot;http://localhost:8001/api/v1/feeds/list/&quot;)
    
  
      const performSearch = () =&gt;  {
        //setLoading(true)
        api.get(currentPageUrl).then(res =&gt; { // axios call 
          setLoading(false)
          setFeed(res.data.results)
        }).catch(function(error){
          console.log(error);
        });
      }
    
      const handleSearch = (e) =&gt;{
        console.log(e.target.value)
        //performSearch();
      }
  
      useEffect(() =&gt; {
          performSearch()
        }, [currentPageUrl]);
      
        if (loading) return &quot;Loading...&quot;
      }
  
  
  export const api = axios.create(
      {baseURL : 'http://localhost:8001/api/v1/feeds/list/'}
      )
  </code></pre>
  <p>user input</p>
  <pre><code>  &lt;input type=&quot;text&quot; placeholder=&quot;Enter  keyword&quot; onChange={event =&gt; handleSearch(event)}/&gt;
  </code></pre>