title: How can I handle search queries in react js?
body: <p>I have my node js server up and running and I handle query requests like this :</p>
  <p>controller.js</p>
  <pre><code>const getUsers = async (req, res, next) =&gt; {
      const age = req.query.age || 1;
      const lessage = req.query.minAge || 1000000000;
      const search = req.query.s || '';
      let users;
      try {
          users = await User.find({ age: { $gt: age, $lt: lessage }, name: { $regex: search } });
      } catch (e) {
          console.log('Could not find users : ' + e);
          next(e);
      }
      res.json(users);
  };
  </code></pre>
  <p>I check if there is query value in the url then use that in mongoose find() method if not use the default value .</p>
  <p>Now my question is how can I handle or basically send these queries in react with radio buttons and inputs and checkboxes ? I've tried to handle it without any library and everytime I missed something or got caught up in a bug .</p>
  <p>I tried like this :</p>
  <pre><code>    const what = loc.length &lt; 1 ? '?' : '&amp;';
      const [ name, setName ] = React.useState('');
      const [ searchName, setSearchName ] = React.useState('');
      const [ radio, setRadio ] = React.useState('');
      const [ place, setPlace ] = React.useState('');
  &lt;select
                  onChange={(e) =&gt; {
                      setPlace(e.target.value);
                      setLoc((prev) =&gt; prev + place);
                  }}
              &gt;
                  &lt;option value=&quot;&quot;&gt;Select place&lt;/option&gt;
                  &lt;option value={`${what}place=us`}&gt;US&lt;/option&gt;
                  &lt;option value={`${what}place=uk`}&gt;UK&lt;/option&gt;
              &lt;/select&gt;
              {place}
              &lt;form
                  onChange={(e) =&gt; {
                      setRadio(e.target.value);
                      setLoc((prev) =&gt; prev + radio);
                  }}
              &gt;
                  &lt;input type=&quot;radio&quot; name=&quot;gender&quot; value={`${what}age=22`} /&gt; Age over 22 &lt;br /&gt;
                  &lt;input type=&quot;radio&quot; name=&quot;gender&quot; value={`${what}ageMin=22`} /&gt; Age lower than 22 &lt;br /&gt;
              &lt;/form&gt;
              {radio}
              &lt;input
                  type=&quot;text&quot;
                  value={name}
                  onChange={(e) =&gt; {
                      setName(e.target.value);
                  }}
              /&gt;
  </code></pre>
  <p>There is no tutorial nor an article on how to send multiple query requests with different options in react .</p>
  <p>So How can I handle sending query requests to the backend with react js ?</p>