Saturday 29 April 2017

javascript, nodejs, requestify timing

What do I have to do to make this work? I've proven the GET is returning successfully and I'm receiving the res.body I'm expecting.

But of course x is 'undefined' because the call to getSometing() isn't going to wait on requestify()

var x = getSomething();

function getSomething() {
    requestify.get('url')
        .then(function res) {
            return(res.body);
        })
        .fail(function err) {
            return("something happened");
        });
}



via user5903880

No comments:

Post a Comment