-1

I'm wondering how to get an array that contains all parameters sent in a HTTP request.

If I read the doc: http://expressjs.com/4x/api.html#req.params

I can see that using req.params and req.query, params will be linked to the route parameters and query to the GET parameters. But how can I log the post parameters? The req.param() method requires an argument and doesn't returns an array if I don't provide one. Since all POST parameters must be used through req.param(), there is no way to log them for now. Or am I missing something?

My goal is to efficiently log all parameters to debug easily the application during development, let me know if you have a better way.

1
  • Yes, it is a duplicate, but the title of the other topic doesn't have express keyword or in its title so I couldn't find it before, not my fault if it's badly indexed. There is no need to downvote my question which is actually much better indexed. What shold we do? Edit the other topic and add express keyword? That's not a problem to close my topic, I just voted for. I'll edit the other one. Commented May 16, 2014 at 23:16

1 Answer 1

4

You're looking for req.body, which contains the parsed POST body. (assuming you have middleware that parses it)

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

5 Comments

wouldn't that require express.bodyParser() or similar ?
@adeneo: Yes; I edited.
Thanks a lot... Never saw this option in the doc, they just talk about it once without any link to it. I do have the midleware.
@SLaks - Yeah, noticed the edit as soon as I posted the comment.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.