title: Req.Body undefined NODE.JS POST Request
body: <p>I'm currently working on a simple Node.JS app that communicates with mysql database. </p>
  
  <p>The app gets data from the database and puts it in a table using app.get and it works fine.</p>
  
  <p>The problem I am having is that req.body is not returning anything when using app.post. The app will submit to the database, but because req.body is not returning anything, the values are null. It will post actual values if I swap the req.body variables with hardcoded variables e.g. "12320".</p>
  
  <p>I have therefore isolated the problem to post requests which use req.body. </p>
  
  <p>If I console log req.body it is empty. </p>
  
  <p>I have read just about every stackoverflow question on this and have not been able to find a solution. </p>
  
  <p>I have tried reinstalling body-parser, express, morgan, and mysql. </p>
  
  <p>I have tried recreating the app in a fresh directory and installing the modules again. </p>
  
  <p>I have tried renaming the variables incase that was having some effect (e.g. name="test", req.body.test)</p>
  
  <p>But all of this was to no avail.</p>
  
  <pre><code>&lt;form id="submit_missing" action="/submit_quote" method="POST" enctype="multipart/form-data"&gt;
  
  &lt;input type="text" id="submit_quote_id" name="submit_quote_id" placeholder="Quote ID"&gt;
  
  &lt;input type="text" id="submit_priority" name="submit_priority" placeholder="Priority" list="priority_list"&gt;
  
  &lt;input type="text" id="submit_customer" name="submit_customer" placeholder="Customer"&gt;
  
  &lt;input type="text" name="submit_who" id="submit_who" placeholder="Who's On it" list="purchasing"&gt;
  
  &lt;input type="text" id="submit_account_manager" name="submit_account_manager" placeholder="Account Manager" list="account_managers"&gt;
  
  &lt;button id="submit_quote"&gt;SUBMIT&lt;/button&gt;
  
  &lt;form&gt;
  </code></pre>
  
  <pre><code>// server.js
  
  const express = require('express')
  const app = express()
  const morgan = require('morgan')
  const mysql = require('mysql')
  const bodyParser = require('body-parser')
  
  app.use(bodyParser.json({ type: '*' }))
  app.use(bodyParser.urlencoded({ extended: true }))
  
  app.use(express.static('./public'))
  app.use(express.static('./files'))
  
  const user = ***
  const pass = ***
  
  function getBoardConnection() {
    return mysql.createConnection({
      host: "localhost",
      port: "3306",
      user: user,
      password: pass,
      database: "board"
    })
  }
  
  app.get('/get_board_quotes', (req, res) =&gt; {
    const con = getBoardConnection()
  
    const queryString = "SELECT * FROM board_quotes WHERE quote_complete = '0'"
    con.query(queryString,(err, rows, fields) =&gt; {
      if (err) {
        console.log("Failed to query for /get_board_quotes : " + err)
      }
      console.log("Getting data from database for /get_board_quotes")
      res.json(rows)
    })
  
  })
  
  
  app.post('/submit_quote/', (req, res) =&gt; {
    console.log(req.body)
     quote_id = req.body.submit_quote_id
     priority = req.body.submit_priority
     customer = req.body.submit_customer
     who_quoted = req.body.submit_who
     account_manager = req.body.submit_account_manager
     type = ""
  
  
     queryString = "INSERT INTO board_quotes (quote_id, priority, customer, who_quoted, account_manager, quote_type) \
     VALUES (?, ?, ?, ?, ?, ?)"
  
     getBoardConnection().query(queryString, [quote_id, priority, customer, who_quoted, account_manager, type], (err, results, field) =&gt; {
       if (err) {
         console.log("Failed to insert new board order " + err)
         return res.redirect('/board/quotes.html')
       }
       console.log("Inserted a new board with id ")
       res.redirect('/board/quotes.html')
     })
  
  })
  
  app.listen(6565, () =&gt; {
    console.log("Server is running")
  })
  
  </code></pre>
  
  <p>Output </p>
  
  <pre><code>
  Server is running
  Getting data from database for /get_board_quotes
  {}
  Failed to insert new board order Error: ER_BAD_NULL_ERROR: Column 'quote_id' cannot be null
  
  </code></pre>
  
  <p>{} is the output for console.log(req.body)</p>
  
  <p>Any help would be greatly appreciated. </p>