title: Express POST Request Appears Undefined in MySQL Database
body: <p>When I submit form data from HTML form, all values added to MySQL database appear as Undefined. I console.logged req.body and it is shown correctly.
  The HTML form in client is a normal form (Important to say that I don't send multipart/form-data, no "enctype" attribute in HTML). I've been looking all over the internet to figure it out what am I doing wrong. I'd like to know what is the problem.
  Here's my backend code: </p>
  
  <pre><code>const express = require('express');
  const bodyParser = require('body-parser'); // Required for POST requests to work
  const mysql = require('mysql');
  const path = require('path');
  const cors = require('cors');
  const app = express();
  const port = 1000; 
  
  app.use(bodyParser.json());
  app.use(express.static(path.join(__dirname, 'public')));
  app.use(express.json());
  app.use(cors());
  
  
  const DB = mysql.createConnection({
        host: 'localhost',
        user: 'root',
        password: '1',
        database: 'onlineshop',
  });
  
  DB.connect(err =&gt; {
      if (err) throw err
      console.log("Connected to MySQL database")
  });
  
  app.use(function (req, res, next) {
      res.header("Access-Control-Allow-Origin", "*");
      res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
    next();
  });
  
  app.post('/register', (req, res) =&gt; {
    let newCustomer = req.body;
    let q = `INSERT INTO customers (firstname, lastname, email, password, city, street, role)
    VALUES ("${newCustomer.firstname}",
            "${newCustomer.lastname}",
            "${newCustomer.email}",
            "${newCustomer.password}",
            "${newCustomer.city}",
            "${newCustomer.address}",
             0`
    const result = DB.query(q, (err,result)=&gt;{ 
        if (err) throw err
        res.json(result)
    })
  });
  
  app.listen(port, console.log('App listening at port 1000'));
  </code></pre>
  
  <p>Thank you!</p>