Express - POST processing - undefined?

Tell us what’s happening:

Repl here is not processing the POST name data. I tried to console.log it and got an error, Cannot read property string of undefined But for adding urlParser, I am using the same function I used for the GET challenge slightly earlier, which it passed.

Your code so far

var bodyParser = require('body-parser');

var urlParser = bodyParser.urlencoded({extended: false});

app.use(urlParser);
app.route('/name')
  .get((req, res) => {
    res.json({
      name: req.query.first + ' ' + req.query.last
      });
    })
  .post(urlParser, (req, res) => {
    console.log(req.query.first)
    res.json({
      name: req.query.first + ' ' + req.query.last
      });
    })

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:80.0) Gecko/20100101 Firefox/80.0.

Challenge: Get Data from POST Requests

Link to the challenge:

Hello!

It works for me. Maybe you didn’t call it correctly: https://boilerplate-express-2.themagicbean.repl.co/name?first=first_name&last=last_name.

This is a picture of a plugin for Firefox called RESTer:

But when I try to input names using the HTML form, I get errors and undefined? (That and it doesn’t pass FCC automatic testing.)

Oh! I see now. Use req.body instead of req.query.