title: Reactjs POST request through axios
body: <p>Hi i am trying reactjs POST request through axios but getting error, I went through all docs but error is not solved.</p>
  
  <p>Here is my error:</p>
  
  <p>Uncaught (in promise) Error: Request failed with status code 400
      at createError (eval at  (bundle.js:4621), :15:15)
      at settle (eval at  (bundle.js:4615), :18:12)
      at XMLHttpRequest.handleLoad (eval at  (bundle.js:4609), :77:7)</p>
  
  <p>Here is my Reactjs code:</p>
  
  <pre><code>import React from 'react';
  import RaisedButton from 'material-ui/RaisedButton';
  import TextField from 'material-ui/TextField';
  import axios from 'axios';
  const style = {
   margin: 15,
  marginLeft: 600
  };
  export default class  Register extends React.Component {
   constructor(props) {
     super(props);
     this.onSubmit=this.handleSubmit.bind(this);
  }
  
  
  handleSubmit(e) {
     e.preventDefault();
     var self = this;
     var data = new FormData();
     const payload = {
     id: 111,
     studentName: 'param',
     age: 24,
     emailId: 2
  };
  data.append("myjsonkey", JSON.stringify(payload));
  
  axios('http://localhost:8083/students',{
     method: 'POST',
     body: data,
     headers: {
      // 'Authorization': `bearer ${token}`,
      'Content-Type': 'application/json'
    }
   })
     .then(function(response) {
         return response.json()
       }).then(function(body) {
         console.log(body);
       });
   }
  
  render() {
     return (
       &lt;form onSubmit={this.onSubmit}&gt;
       &lt;div style={style}&gt;
       &lt;TextField ref='id'
       hintText="Enter Student id"
       floatingLabelText="id"
       /&gt;
       &lt;br/&gt;
       &lt;TextField ref='sname'
       hintText="Enter your Last Name"
       floatingLabelText="StudentName"
       /&gt;
       &lt;br/&gt;
       &lt;TextField ref='age'
       hintText="Enter your Age"
       floatingLabelText="age"
       /&gt;
       &lt;br/&gt;
  
       &lt;TextField ref='emailId'
       hintText="Enter your Email"
       floatingLabelText="emailId"
       /&gt;
       &lt;br/&gt;
       &lt;br/&gt;
       &lt;input type="submit" /&gt;
  
  
       &lt;/div&gt;
           &lt;/form&gt;
  
  
     );
   }
  
  
  }
  </code></pre>