Tell us what’s happening:
Describe your issue in detail here.
pls how do i get this code to res.json the values, cos it sends, undefine first name and last, i have required and used the body-parser both with urlencoded and .json, it logs the values to the console but sends undefined to the client
Your project link(s)
app.post('/name', (req, res) => {
const firstname = req.body.first;
const lastname = req.body.last;
console.log(firstname + " " + lastname)
const names = firstname + " " + lastname
res.json({name: names })
})
solution: boilerplate-express (1) - Replit
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36
Challenge: Basic Node and Express - Use body-parser to Parse POST Requests
Link to the challenge: