var getDataFromUrl = function(url) {
    rest.get(url).on('complete',function(data) {
        if(data instanceof Error) {
            console.log("url error");
            process.exit(1);
        }else {return data};
     });
};

when this function (getDataFromUrl) is called by another function it return undefine
what is happing

It looks as if the outermost function getDataFromUrl does not return anything.

this is the corret way the code should be

var getDataFromUrl = function(url) {
    rest.get(url).on('complete',function(data) {
        if(data instanceof Error) {
            console.log("url error");
            process.exit(1);
        }
        //data is return if data is not an instanceof Error
        return data
     });
};
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.