Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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.

Thanks!

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

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.