Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript Build a Simple Dynamic Site with Node.js HTTP Methods and Headers Dealing with the POST Body

Sean Gabriel Villoria
Sean Gabriel Villoria
8,515 Points

Where did postBody come from?

I've searched through the code but I can't seem to find postBody declared anywhere.

Am I correct to assume this means it's because it's just an inherent argument passed by the POST method? Why can't I find it mentioned in the API docs?

Where can I read more about it?

Just trying to understand where it came from.


The postBody is the variable name given to the data passed into the function returned by the request.on('data') event handler. When this event handler was used previously the function variable was just called 'data' I think but in this case was given a more descriptive variable name.

1 Answer

13,655 Points

To further clarify on Brian Wright, the postBody is also the PARAMETER name (not argument) given in the callback function in request.on() . The parameters in a function can be named anything.