I'm not sure why I have to call the getInfo function twice to actually get a value. The first time returns undefined, which I thought the variable would have been set after the JSON.parse. It returns with the actual value if I call the getInfo function again.
var myVariable
exports.getInfo = function(){
exports.JSONData()
return myVariable
}
exports.JSONData = function(){
var req = http.get('JSONFILELINK', function(res){
var body = ''
res.on('data', function(chunk){
body += chunk
})
res.on('end', function() {
var info = JSON.parse(body)
myVariable = info.my.value
})
})
}