title: React POST requests with Express/Node and MongoDB
body: <p>I'm writing program that uses React as front-end, and an Express/Node API for the backend which then does CRUD operations in a MongoDB database. Right now, I'm using the native JS fetch() API to perform GET/POST operations on my front end. The GET requests work just fine, but my POST requests seem to not be working. On my front end, I have a form and a handler for form submission like so: </p>
  
  <pre><code>handleSubmit(){
      let databody = {
          "name": this.state.nameIn,
          "quote": this.state.quoteIn
      }
  
      return fetch('http://localhost:5002/stored', {
          method: 'POST',
          body: JSON.stringify(databody),
          headers: {
              'Content-Type': 'application/json'
          },
      })
      .then(res =&gt; res.json())
      .then(data =&gt; console.log(data)); 
  }
  
  
  render(){
      return (
          &lt;div&gt;
              &lt;form onSubmit={this.handleSubmit}&gt;
                  &lt;label&gt;
                      Name
                      &lt;input type="text" name="name" value={this.nameIn} onChange={this.handleNameChange}/&gt;
                  &lt;/label&gt;
                  &lt;label&gt;
                      quote
                      &lt;input type="text" name="quote" value={this.quoteIn} onChange={this.handleQuoteChange}/&gt;
                  &lt;/label&gt;
                  &lt;input type="submit" value="Add to DB" /&gt;
              &lt;/form&gt; 
          &lt;/div&gt;
      );
  }
  </code></pre>
  
  <p>Then on my Express API, which is on port 5002, I have:</p>
  
  <pre><code>app.post('/stored', (req, res) =&gt; {
      console.log(req.body);
      db.collection('quotes').insertOne(req.body, (err, data) =&gt; {
          if(err) return console.log(err);
          res.send(('saved to db: ' + data));
      })
  });
  </code></pre>
  
  <p>However, when the form is submitted, the request shows up on the Express API with an empty body. The console.log shows that req.body is just an { } I'm wondering what I did wrong?</p>