function readTextFile(filename, callback){
    var fs = require('fs');
    fs.readFile(filename, 'utf8', function(err, data){
        if(err){
            throw err;
        }else{
            callback(data);
        }
    });
}
var set1 = [];
var set2 = [];
var set3 = [];
var set4 = [];
var set5 = [];
readTextFile("./data/names.json", function(text){
    var names = JSON.parse(text);
    set1 = names.prop1.prop2;
    set2 = names.prop1.prop3;
    set3 = names.prop1.prop4;
    set4 = names.prop5.prop2;
    set5 = names.prop5.prop3;
});
console.log(set1);
Running this section of code, using "node jsonRead.js" returns [ ] for any array called in console.log(). This section of code used to work about 80% of the time, but now it doesn't work at all, and I'm not sure why. I would appreciate any advice on how to get it working again.
 
     
    