Sunday, 7 May 2017

Why can't I make http.get send .json output to a variable using node.js in AWS lambda?

I've been spending hours and hours trying to get the below code to work, but I just can't make it send the .json output to anything but the log (which is worthless).

var kevin = http.get(options, function(res) {
    var body = '';
    res.on('data', function(chunk) {
        body += chunk;
    });
    res.on('end', function() {
        var parsed = JSON.parse(body);
        return parsed; 
    });
}).on('error', function(e) {
    console.log("Got error: " + e.message);
});         


console.log(kevin);

here I want to take 'kevin', parse it, and do more things with it. why is this not possible?! Or, is my only choice to write the log, somehow retrieve the log, and go from there?

I'm posting here because it seems Amazon has banned me from their forums before I've even made my first post.



via Kevin Key

No comments:

Post a Comment