I was just wondering if the NodeJS https.get() method/function was asynchronous or not?
I'm still learning, but it seems like it is, since it was producing results before other code of mine, but I could be wrong.
Also, is https.get technically a function, or method? I wasn't sure when writing the title.
This is what I'm talking about:
https://nodejs.org/api/https.html#https_https_get_url_options_callback
Top comments (1)
Hi Russell, I did a quick test taking the example in nodejs.org/api/https.html#https_ht... and adding something like:
and it printed "after" before the callback but it could have printed in the correct order, that's the nature of async. You can't expect the callback to finish before the code after it.
I'm not surprised as most things are async in Node.
It's both:
but also
get
is a function operating on (better said "scoped to") the https object, therefore it's a method of the object, but it's also a function.In this case
get
is a method of the objecthttps
which accepts a URL and a function as arguments.Hope this helps!