title: How to better way to send optional params in react JS with AXIOS Api call
body: <p>I am trying to make API in React JS with AXIOS. I need to send different types of params depends on params availability. Currently, I am calling like the below snippet and it is working as expected. The code becomes more lengthy when I have more optional values. How I can simplify or optimise the below api call</p>
  <pre><code>const axiosHandler = () =&gt; {
     
          let request;
          if (productID &amp;&amp; type) {
              request = common.fetchDetails(
                  { productID: productID, type: type },
                  {
                      assignedTo: popUpID.current.toString(),
                      selectedItems: checkedItems,
                  },
              );
          } else if (productID) {
              request = common.fetchDetails(
                  { productID: productID },
                  {
                      assignedTo: popUpID.current.toString(),
                      selectedItems: checkedItems,
                  },
              );
          } else if (type) {
              request = common.fetchDetails(
                  { type: type },
                  {
                      assignedTo: popUpID.current.toString(),
                      selectedItems: checkedItems,
                  },
              );
          } else {
              request = common.fetchDetailsWithoutParams({
                  assignedTo: popUpID.current.toString(),
                  selectedItems: checkedItems,
              });
          }
          request
              .then((res) =&gt; {
                  console.log('res', res);
              })
              .catch((err) =&gt; {
                  console.log('err', err);
              });
      };
  </code></pre>