2

When using body-parser in node.js, I want the send keys be case insensitive. suppose that we send a json such as { "Name" : "Dariush" } and I want to get 'Name' value, in two ways:

request.body.name & request.body.Name

But by default, just request.body.Name works! and I want the 'request.body.name' works too.

1 Answers1

2

Pre-process request.body keys with a lower case function and use only request.body.name.

Please, follow the answer https://stackoverflow.com/a/17945574/84661

There is also an express.js middleware for a related purpose: https://www.npmjs.com/package/express-uncapitalize

Brian Cannard
  • 852
  • 9
  • 20