i've got some txt files that have json data in them i'm reading them, then trying to get data
async function asda() {
var files = await fs.readdirSync(__dirname);
files = files.filter((file) => file.endsWith(".txt"));
var data = {};
files.forEach(async (file) => {
filedata = await fs.readFileSync(__dirname + `/${file}`);
viewers = await JSON.parse(filedata).chatters;
data[file] = viewers;
});
console.log(data);
}
asda();
file
is a string data
is an object but it logs an empty object at the end. What causes this?