I'm sure this has already been answered but I can't find the exact question I'm looking for.

I have an ejs file that has this for the form.

```
<form action="" method="POST">
   <div class="input-group">
      <input type="text" class="form-control" name="userSearchInput" placeholder="Enter the id of the product you would like to buy" aria-label="Recipient's username" aria-describedby="basic-addon2">
      <div class="input-group-append">
           <button class="btn btn-outline-secondary" id="searchBTN" type="submit"><i class="fas fa-cart-plus mr-2"></i>Add to Cart</button>
    </div>
 </div>
</form>

```

On the node side in my app.js file, I've installed and downloaded both express and body-parser and done the requisite require function.

```
var bodyParser = require('body-parser');
var express = require('express');
var app = express();

```

I've set up my middleware for body-parser here:

```
// middleware for bodyParser
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));

```

Then, to get the content of what the user types into the input text box, I'm using this:

```
app.post('/', function(req, res) {
    var item = req.body.userSearchInput;
    console.log(item);
});

```

This is my first time using app.post and since nothing is being console logged- I'm not sure where I'm going wrong.

full app.js file

```
var express = require('express');
var path = require('path');
var http = require('http');
var mysql = require('mysql');
var bodyParser = require('body-parser');
var nodemon = require('nodemon');

var app = express();

var port = process.env.PORT || 3000;

// setting up views
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
app.use(express.static(path.join(__dirname, 'public')));

// middleware for bodyParser
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));

// create connection to mySQL db
var connection = mysql.createConnection ({
    host     : 'localhost',
    user     : 'root',
    password : 'root',
    database : 'bamazon'
});

// initialize connection
connection.connect();

// run db query and print items to index html home page
connection.query('SELECT * from products', function (error, results) {
    if (error) throw error;
    console.log(results);
    app.get('/', function(req, res){
        res.render('index', {list: results});
    })
});

app.post('/', function(req, res) {
    var item = req.body.userSearchInput;
    console.log(item);
});

// setting up listen for server function
app.listen(port, function (err) {
    if (err) throw err;
    console.log("Server is running on port " + port);
});

```