1

I don't know what this is not working when it work in my previous pages.

input.form-control(type="text", name="names[]", autocomplete="off")

I want to retrieve that value in my server. In my other pages I use this

console.log("value " + req.body["names[]"]);

I typically get an array of names. Now for some reason all I get is undefined I have tried for hours I just don't know what is wrong.

1 Answer 1

1

req.body is undefined by default according to the Express Docs. You'll need a middleware like body-parser to grab pieces of req.

1) npm install body-parser
2) Towards the top of server file - var bodyParser = require('body-parser');
3) after var app = express() include app.use(bodyParser.json());

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.