0
 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

Edited by otengkwaku

2
Contributors
2
Replies
21
Views
4 Years
Discussion Span
Last Post by otengkwaku
0

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

0

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
     });
};
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.