So this seems like a basic thing but has caused extra work on my end this week several times. How do I define a variable within a function and make it available outside of said function.
var variables = { initial: 'To Start'};
var curl = require('curlrequest');
var options = {
url: 'www.google.com',
verbose: true,
stderr: true
};
curl.request(options, function (err, data) {
variables.testing123 = function() {return 'woking now';};
variables.ting123 = 'I should be showing in console';
});
console.log(variables);
Console Output:
{ initial: 'To Start' }
The goal is to curl a url and store the returned json into a varialble to be used in another function to sort out highest resolution and build a download list from the available data. The latter part of the script is ready and but in order to dynamically do this I need to curl several urls and filter the json for each.