1

So I want to use for my form, inputs like this: input name="register[email]"

But I can not seem to get in router in nodejs the value from input. I used req.body.register.email , reg.body.register['email']. Nothing seem to work.

When I use for input name="email" I can simply use req.body.email and works just fine.

1
  • What do you mean in Java? Commented Feb 27, 2016 at 10:13

1 Answer 1

2

You can access input via req.body['register[email]'].

Or, if you use Express, set option extended for body-parser.urlencoded in true:

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

and simple use req.body.register.email.

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

2 Comments

works just fine , thank you. Can you give me some information about extended: true , false ? what influence it will have on my code?
When true - body-parser uses qs library (instead querystring module) which allows create nested object from query string. [github.com/expressjs/body-parser#extended]

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.