REACT fetch post request REACT fetch post request mongodb mongodb

REACT fetch post request


I guess the way you are using ref has been deprecated. try below see if you have any luck.

export default class Form extends React.Component { constructor(props){  super(props);  this.handleSubmit = this.handleSubmit.bind(this); } handleSubmit(event){   event.preventDefault();  fetch('/', {   method: 'post',   headers: {'Content-Type':'application/json'},   body: {    "first_name": this.firstName.value   }  }); }; render () {  return (      <div id="signup">    <form onSubmit={this.handleSubmit}>        <input ref={(ref) => {this.firstName = ref}} placeholder="First Name" type="text" name="first_name"/><br />        <input ref={(ref) => {this.lastName = ref}} placeholder="Last Name" type="text" name="last_name"/><br />       <button type="Submit">Start</button>    </form></div>​  ) }}