It’s because https.get
is asynchronous, so NodeJs don’t wait this call and immediately executes console.log('message2');
.
That way we can not to wait async call completion and continue doing something. After that request finished successfully you’ll get console.log('message');
CLICK HERE to find out more related problems solutions.