title: reactjs- Axios post returns empty object
body: <p>New to Reactjs. I'm trying to post data to a local server using axios, but it is returning an empty object. What am i doing wrong? I need to send a name and an email to the json file.</p>
  <pre><code>const FormNew = () =&gt; {
    const [name, setName] = useState(&quot;&quot;);
    const [email, setEmail] = useState(&quot;&quot;);
  
    const handleChangeName = (event) =&gt; {
      setName(...name, { name: event.target.value });
    };
  
    const handleChangeEmail = (event) =&gt; {
      setEmail(...email, { email: event.target.value });
    };
  
    const handleSubmit = (event) =&gt; {
      event.preventDefault();
  
      axios
        .post(&quot;http://localhost:3002/posts&quot;, {
          name: name,
          email: email,
        })
        .then((res) =&gt; {
          console.log(res.data);
        });
    };
  
    return (
      &lt;Form onSubmit={handleSubmit}&gt;
        &lt;Field.Text
          label=&quot;Name&quot;
          name=&quot;name&quot;
          type=&quot;text&quot;
          onChange={handleChangeName}
        /&gt;
        &lt;Field.Text
          label=&quot;Email&quot;
          name=&quot;email&quot;
          type=&quot;email&quot;
          onChange={handleChangeEmail}
        /&gt;
        &lt;Button type=&quot;submit&quot;&gt;Submit&lt;/Button&gt;
      &lt;/Form&gt;
    );
  };
  export default FormNew;
  
  </code></pre>
  <p>Json file where i'm trying to send data.</p>
  <pre><code>{
    &quot;posts&quot;: [
      {
        &quot;name&quot;: &quot;JSON SERVER&quot;,
        &quot;email&quot;: &quot;json@net.com&quot;,
        &quot;id&quot;: 1
      }
    ]
  }
  
  </code></pre>