title: React.js: Pass value from form to axios POST request
body: <p>I'm very confused with what I am doing right now</p>
  
  <p>I'm trying to pass form data into an axios POST request and I'm not sure what I am doing wrong</p>
  
  <p>Here is the code of the form:</p>
  
  <p><strong>ClientMaintenancePage.js</strong></p>
  
  <pre><code>const [dataBanks, setDataBanks] = useState([]);
  const [optionsBrstn, setOptionsBrstn] = useState('');
  
  ...
  
  const retrieveBanks = useCallback(() =&gt; {
  ClientMaintenanceService.retrieveBanks()
  .then((response) =&gt; {
    console.log("ClientMaintenancePage - retrieveBanks response.data &gt;&gt;&gt; " + response.data)
    setDataBanks(response.data);
  }).catch((err) =&gt; {
    console.log("ClientMaintenancePage - retrieveBanks catch &gt;&gt;&gt; " + err)
  })
  });
  
  const saveBrstn = useCallback(() =&gt; {
  ClientMaintenanceService.saveBankMaintenance(optionsBrstn)
  .then((response) =&gt; {
    console.log("ClientMaintenancePage - saveBrstn response.data &gt;&gt;&gt; " + response.data)
  }).catch((err) =&gt; {
    console.log("ClientMaintenancePage - saveBrstn catch &gt;&gt;&gt; " + err)
  })
  });
  
  useEffect(() =&gt; {
  retrieveBanks();
  }, []);
  
  ...
  
  const newOptions = dataBanks.map(({BIC, BRSTN, NAME}) =&gt; ({
  label: BIC + "  " + BRSTN + "  " + NAME ,
  value: BRSTN
  }))
  
  return (
  &lt;Select 
            id="selectBrstn"
            isSearchable="true"
            options={ newOptions } 
            placeholder="Select BIC / BRSTN / Bank Name..." 
            value={ optionsBrstn }
            onChange={ setOptionsBrstn }
          /&gt;
  )
  </code></pre>
  
  <p>I'm trying to save the value of dropdown</p>
  
  <p>So I'm passing the value to axios POST request. However, I can't get the value properly</p>
  
  <p>Please enlighten me on what am I missing.</p>
  
  <p>Also, here is the code of my POST request:</p>
  
  <p><strong>ClientMaintenanceService.js</strong></p>
  
  <pre><code>const LOCAL_API_URL_SAVE_BANK_MAINTENANCE = "http://XX.XX.XX.XX:8080/cpex/bank/maintenance/save"
  
  saveBankMaintenance(optionsBrstn){
      console.log("saveBankMaintenance axios.post - optionsBrstn &gt;&gt;&gt; " + optionsBrstn)
      return axios.post(`${LOCAL_API_URL_SAVE_BANK_MAINTENANCE}`, {
          brstn: optionsBrstn
      })
  }
  </code></pre>
  
  <p>If I'm correct, I think have the value of the dropdown in my state <em>optionsBrstn</em></p>
  
  <p>I passed it as a paramter on my service call but somehow I don't get it as String</p>
  
  <p>TIA</p>