I want get the every data on the folder to nodeJS my code can read the data but can't assign the data to object I want just read and can assign the code even don't use the object
can you help me?
I'm not good well english so if you point out the my mistake I will very thankful
The code:
var fs = require('fs');
//get the every source of the file that in the data folder
fs.readdir(`data`, function(error, file) {
var newObject = {};
file.forEach(function (element) {
newObject[element]=0;
});
for(var key in newObject) {
fs.readFile(`data/${key}`,'utf8', function(err, des){
newObject[`${key}`]=`${des}`;
console.log(`${des}`);
});
}
console.log(newObject);
});