JavaScript Node.js Basics Building a Command Line Application Getting the Response Body

FunctionData

Does the function needs to be called data?

1 Answer

Steven Parker
Steven Parker
179,664 Points

I believe you're referring to the callback function passed to "response.on". That is an anonymous function (it has no name), but it takes a parameter named "data" in the video. The parameter name is not important other than it is considered a "best practice" to give parameters names that reflect their purpose. But it would function the same if you changed the parameter name to "bob" or "fish" or any other valid identifier name.