title: TypeError: Cannot read properties of undefined (reading 'email') and Failed to load resource: net::ERR_CONNECTION_REFUSED
body: <p>front end login page
  This is my code for login page. I am trying to use axios to send data from the front end to the back end. There seems to be a problem while performing axios.post as it gives an output saying network error. It does not specify the exact error, so I am confused as to how to go about debugging the same.
  Please go through it and let me know the solution for it</p>
  <p>function Login() {</p>
  <pre><code>const [email, setEmail] = useState(&quot;&quot;);
  const [password, setPassword] = useState(&quot;&quot;);
  
  
  const handleSubmit = async e =&gt; {
      e.preventDefault();
      
      try {
          Axios({
              method: 'post',
              url: 'http://localhost:8000/Login',
              data: {
                email: email,
                password:password
              }
            });
          console.log(email)
      } catch (e) {
          if (!e.response) {
              // network error
              this.errorStatus = 'Error: Network Error';
          } else {
              this.errorStatus = e.response.data.message;
              console.log(this.errorStatus)
          }
        }
        setEmail(&quot;&quot;)
        setPassword(&quot;&quot;)
      }
  
  
  return (
      &lt;div className=&quot;sign__in&quot; style={{textAlign:'center'}}&gt;
         &lt;h3 style ={{marginLeft: &quot;-7%&quot; }}&gt;I already have an account&lt;/h3&gt;
         &lt;span style={{marginLeft: &quot;-5%&quot;}}&gt;Sign In With Your Email And Password&lt;/span&gt;
          &lt;form  className=&quot;form&quot;&gt;
              &lt;input autoComplete=&quot;off&quot; className=&quot;signIn form-control&quot;placeholder=&quot;Email&quot; value={email} type=&quot;email&quot; name=&quot;email&quot; onChange={e =&gt; setEmail(e.target.value)}/&gt;
              &lt;input autoComplete=&quot;off&quot; className=&quot;signIn form-control&quot; placeholder=&quot;password&quot; value={password} type=&quot;password&quot; name=&quot;password&quot; onChange={e =&gt; setPassword(e.target.value)}/&gt;
              
          &lt;/form&gt;
          &lt;button onClick={handleSubmit} className=&quot;button&quot;&gt;
                  SIGN IN
          &lt;/button&gt;
      &lt;/div&gt;
  )
  </code></pre>
  <p>}</p>
  <p>backend api.js file</p>
  <p><a href="https://i.stack.imgur.com/Deaxs.png" rel="nofollow noreferrer">enter image description here</a></p>