Response object is empty and undefined

344 views Asked by At
const express = require("express");
const app = express();
const oracle = require("oracledb");
const bodyParser = require("body-parser");

const urlEncodedBodyParser = bodyParser.urlencoded({ extended: true });
app.use(express.json());
app.post("/addPlacement", urlEncodedBodyParser, function (request, response) {
  console.log(request.body);
  console.log(request.body.id);
  /*
  console.log(request.body.name);
  console.log(request.body.placementType);
  console.log(request.body.company);
  console.log(request.body.salary);
  console.log(request.body.salaryType);
  */
  // console.log(request);

  response.send(request.body);
});

app.listen(5050, function (err) {
  if (err) {
    console.log(err);
  }
  console.log("Server is ready to request on port 5050");
});

If I console log the request.body it shows undefined and sends the empty object and in case console.log(request) I get this error.

Advanced REST Client request (image)

0

There are 0 answers