-1

First of all I have tried this, this and this.

app.use(bodyParser.json())
app.use(bodyParser.urlencoded({extended: false}))

app.post('/user_create', (req,res) => {
    console.log("trying to create a user "+req.body);

    const firstName = req.body.first_name
    const lastName = req.body.last_name

    console.log("first name is "+firstName+" "+lastName);

    res.end()
})

Now after trying all the post given above, I am still getting req.body undefined, I am newbie in Nodejs. I am using express 4.16.4 and body-parser 1.18.3.

halfer
  • 19,824
  • 17
  • 99
  • 186
Vivek Pratap Singh
  • 1,564
  • 16
  • 26

1 Answers1

0
let options = {
    headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded'),
};
jcuypers
  • 1,774
  • 2
  • 14
  • 23