Mount a POST handler at the path /name. It’s the same path as before. We have prepared a form in the html frontpage

Below code is not working for the post handler to get the data in HTML form don’t understand what I m doing wrong. Thanks in advance
var express = require(‘express’);
var app = express();
var bodyParser = require(‘body-parser’);
var urlencodedParser = bodyParser.urlencoded({ extended: true })
app.post(’/name’, urlencodedParser, (req, res) => {
let name = req.body.first + ’ ’ + req.body.last;
res.json({name: name});

});

module.exports = app;

Your code so far

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.63 Safari/537.36

Challenge: Get Data from POST Requests

Link to the challenge:

mebbe try
app.use(bodyParser.urlencoded({ extended: true }));

then you can use it in your route…
app.post(’/name’ , (req, res) => {

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.