title: I am new to React hooks and trying this code for submitting the form. I am getting this error
body: <p>With the below code i am able to save <strong>userDetails</strong> to the database but i am not getting the <em><strong>console.log(result.data)</strong></em> output.</p>
  <pre><code>
      import React, { useState, useEffect } from &quot;react&quot;;
      import &quot;bootstrap/dist/css/bootstrap.min.css&quot;;
      import axios from &quot;axios&quot;;
      const AnotherForm = () =&gt; {
        const [fullName, setName] = useState();
        const [userName, setUserName] = useState();
        const [email, setEmail] = useState();
        const [password, setPassword] = useState();
      
        const onSubmitting = async (e) =&gt; {
          // e.preventDefault();
          // console.log(name);
          // console.log(userName);
          // console.log(email);
          // console.log(password);
          const UserDetails = { fullName, userName, email, password };
          const result = await axios.post(
            &quot;http://localhost:5000/app/signup&quot;,
            UserDetails
          );
          try {
            console.log(result.data);
          } catch (error) {
            console.error(error);
          }
          console.log(result);
        };
        useEffect(() =&gt; {
          onSubmitting();
        }, []);
        return (
          &lt;div className=&quot;form-div&quot;&gt;
            &lt;form onSubmit={onSubmitting}&gt;
              &lt;input
                type=&quot;text&quot;
                placeholder=&quot;Full Name&quot;
                onChange={(e) =&gt; setName(e.target.value)}
                className=&quot;form-control form-group&quot;
              /&gt;
      
              &lt;input
                type=&quot;text&quot;
                placeholder=&quot;User name&quot;
                onChange={(e) =&gt; setUserName(e.target.value)}
                className=&quot;form-control form-group&quot;
              /&gt;
              &lt;input
                type=&quot;text&quot;
                placeholder=&quot;Email&quot;
                onChange={(e) =&gt; setEmail(e.target.value)}
                className=&quot;form-control form-group&quot;
              /&gt;
              &lt;input
                type=&quot;password&quot;
                placeholder=&quot;Password&quot;
                onChange={(e) =&gt; {
                  setPassword(e.target.value);
                }}
                className=&quot;form-control form-group&quot;
              /&gt;
              &lt;input
                type=&quot;submit&quot;
                value=&quot;Submit&quot;
                className=&quot;btn btn-danger btn-block&quot;
              /&gt;
            &lt;/form&gt;
          &lt;/div&gt;
        );
      };
      
      export default AnotherForm;
  
  </code></pre>
  <blockquote>
  <p>I am getting this error in the browser's console</p>
  </blockquote>
  <pre><code>POST http://localhost:5000/app/signup net::ERR_EMPTY_RESPONSE
  dispatchXhrRequest @ xhr.js:177
  xhrAdapter @ xhr.js:13
  dispatchRequest @ dispatchRequest.js:52
  Promise.then (async)
  request @ Axios.js:61
  Axios.&lt;computed&gt; @ Axios.js:87
  wrap @ bind.js:9
  onSubmitting @ Another.file.forForm.withHooks.js:18
  (anonymous) @ Another.file.forForm.withHooks.js:30
  invokePassiveEffectCreate @ react-dom.development.js:23487
  callCallback @ react-dom.development.js:3945
  invokeGuardedCallbackDev @ react-dom.development.js:3994
  invokeGuardedCallback @ react-dom.development.js:4056
  flushPassiveEffectsImpl @ react-dom.development.js:23574
  unstable_runWithPriority @ scheduler.development.js:646
  runWithPriority$1 @ react-dom.development.js:11276
  flushPassiveEffects @ react-dom.development.js:23447
  (anonymous) @ react-dom.development.js:23324
  workLoop @ scheduler.development.js:590
  flushWork @ scheduler.development.js:545
  performWorkUntilDeadline @ scheduler.development.js:157
  createError.js:16 Uncaught (in promise) Error: Network Error
      at createError (createError.js:16)
      at XMLHttpRequest.handleError (xhr.js:84)
  </code></pre>
  <blockquote>
  <p>I am also not able to use <code>e.preventDefault()</code> method inside my code, i am getting the below error. At present, <code>e.preventDefault()</code> is commented in the code.</p>
  </blockquote>
  <p>Unhandled Rejection (TypeError): Cannot read property 'preventDefault' of undefined</p>
  <p>The above are the two concerns with the code.</p>
  <blockquote>
  <p><em>Do i need to use <code>preventDefault()</code> method in the above code</em> or is it okay to remove it!!</p>
  </blockquote>
  <p><strong>Any help is appreciated</strong></p>