Philip Bradbury33,368 Points
Why does the call back function run when not called only assigned?
Im viewing this video a little confused. The Https.get() is assigned to request. request is not called anywhere in the app.js it in only assigned. With this been the case why does the callback execute the console.dir() inside the callback? Shouldn't this only run when the request is called?
Steven Parker177,696 Points
The request variable is not a function.
When you say "request is not called anywhere..." it sounds like you are expecting request to contain a reference to a function, but it does not. In the assignment of request,
https.get() is called, and it is the result of that call (and not the method itself) that is stored in request. The result is an http.ClientRequest object.
Just calling the
https.get() method sets the callback to run when the request completes. So there's no need to make use of request just for this to happen.