title: Axios post is giving me an error: Internal server Error
body: <p>I am doing a post request with Axios and gives me this error:</p>
  
  <blockquote>
    <p>xhr.js:178 POST <a href="http://localhost:3000/dependentes" rel="nofollow noreferrer">http://localhost:3000/dependentes</a> 500 (Internal Server
    Error)</p>
  </blockquote>
  
  <p>I have seen people asking about this but none of their solutions work for me!
  I don't know if is something wrong in this component or I have something wrong with the server side.</p>
  
  <pre><code>import React, { Component } from "react";
  import axios from "axios";
  
  class LogIn extends Component {
    constructor(props) {
      super(props);
      this.state = {
        email: "",
        password: ""
      };
      this.handleSubmit = this.handleSubmit.bind(this);
      this.handleChangeEmail = this.handleChangeEmail.bind(this);
      this.handleChangePass = this.handleChangePass.bind(this);
    }
  
    handleChangeEmail = e =&gt; {
      this.setState({ email: e.target.value });
      //console.log(e.target.value);
    };
  
    handleChangePass = e =&gt; {
      this.setState({ password: e.target.value });
      //console.log(e.target.value);
    };
  
    handleSubmit = e =&gt; {
      /*this.props.history.push('/');
          console.log(this.props);*/
  
      event.preventDefault();
  
      let data = JSON.stringify({
        email: this.state.email,
        password: this.state.password
      });
      let url = "http://localhost:3000/dependentes";
      const response = axios.post(url, data, {
        headers: { "Content-Type": "application/json" }
      });
    };
  
    render() {
      return (
        &lt;div className="container"&gt;
          &lt;form onSubmit={this.handleSubmit} className="white"&gt;
            &lt;h5 className="grey-text text-darken-3"&gt;Log In&lt;/h5&gt;
            &lt;div className="input-field"&gt;
              &lt;label htmlFor="email"&gt;Email&lt;/label&gt;
              &lt;input
                type="email"
                id="email"
                onChange={this.handleChangeEmail}
                value={this.state.email}
              /&gt;
            &lt;/div&gt;
            &lt;div className="input-field"&gt;
              &lt;label htmlFor="password"&gt;Password&lt;/label&gt;
              &lt;input
                type="password"
                id="password"
                onChange={this.handleChangePass}
              /&gt;
            &lt;/div&gt;
            &lt;div className="input-field"&gt;
              &lt;button className="btn orange lighten-1 z-depth-0"&gt;Log In&lt;/button&gt;
            &lt;/div&gt;
          &lt;/form&gt;
        &lt;/div&gt;
      );
    }
  }
  
  export default LogIn;
  </code></pre>