title: How can I insert request body into a MySQL database using express js?
body: <p>So I am trying to make a small api with <code>MySQL</code> and <code>Express JS</code>, after following a small tutorial online on how to use <code>MySQL</code> with <code>Express</code> I tried to make this api and send requests with the <code>postman</code>, to insert the data I sent using postman I used in my code the <code>req.body.data</code> syntax, I tried using tha classic <code>SQL</code> syntax of <code>INSERT INTO table (col1, col2) VALUES (val1, val2)</code> using interpolation for the request body and I also tried the <code>SET ?</code> as I saw in the tutorial I watched. When trying to send the request with postman I keep getting the <code>Cannot read property 'title' of undefined</code> error. How can I insert data that I send to the table with postman?</p>
  
  <p><strong>JavaScript</strong></p>
  
  <pre><code>app.get('/addtodo' , (req, res) =&gt; {
      let sql = 'INSERT INTO todo SET ?'
      let post = {
          title: req.body.title,
          body : req.body.body,
          date: req.body.date,
          importance: req.body.importance
      }
      db.query(sql, post, (err, res) =&gt; {
          if(err) throw err;
          console.log('success');
          console.log(res);
      });
  });
  </code></pre>