The closest you could get to "returning the response" in this case is to
return a Promise, but that's probably a whole other discussion (which I
can't describe any better than Marc Harter did in
http://strongloop.com/strongblog/promises-in-node-js-with-q-an-alternative-to-callbacks/
 ).

Promises or not, however, you won't be able to get around the fact that the
response will be asynchronous and your response handling code will be
called "some time in the future".

~Ryan

On Tue Jan 06 2015 at 4:17:43 PM Tiago Hillebrandt <
[email protected]> wrote:

> Hey guys,
>
> I need to do an HTTPS request to the Linode API.
>
> That said, I am looking if would be possible to return an HTTPS response
> as value on this function: http://paste.ubuntu.com/9684987/
>
> I tried some specific things to make the thread wait until request ends,
> like *setTimeout()* and *while (!req.finished) {}*, but nothing seems to
> work as expected.
>
> This is my first Node.js implementation, so I am not sure if this would be
> the better way to perform this action.
>
> Do you guys have any suggestions on this?
>
> Thanks in advance!
>

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/CAGjmZGyFSF60iVSbXcwHqjUMQFT37cfFgnPbfDUsosaHDQ62HA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to