Here is the code for my simple form
<form action="/form" id="myForm" method="POST">
<input
type="text"
name=""
id="searchBox"
placeholder="Enter Search Term"
required
/>
<label for="pricingOptions">Choose Pricing</label>
<select id="pricingOptions">
<option value="--">None</option>
<option value="Free">price-paid</option>
<option value="Paid">price-free</option>
</select>
<select id="durationOptions">
<option value="--">None</option>
<option value="Free">short</option>
<option value="Paid">long</option>
<option value="Paid">medium</option>
<option value="Paid">extraLong</option>
</select>
<label for="SearchOrder">Order by :</label>
<select id="searchOrder">
<option value="--">Default</option>
<option value="relevance">Relevance</option>
<option value="most-reviewed">most-reviewed</option>
<option value="highest-rated">highest-rated</option>
<option value="newest">newest</option>
<option value="price-low-to-high">price-low-to-High</option>
<option value="price-high-to-low">price-high-to-low</option>
</select>
<input type="submit" id="submitButton" value="submit" />
</form>
I am trying to get the user's input and console.log it. My end goal is to store them in variables and use them to call my API but the post request is returning an empty object.
const express = require("express");
const bodyParser = require("body-parser");
const courseRouter = express.Router();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
courseRouter.get("/form", (req, res) => {
res.render("form");
});
courseRouter.post("/form", (req, res) => {
console.log(req.body);
});
module.exports = courseRouter;