I have a folder that contains 13 Json files. I need to get all of those file's data and number of those files and putting data's in a query and export variables out of function. I tried with fs but I got some problems like I cant get data's out and I dont really understood it.
The Main File's code:
var dosya = {
bilgi: [],
sayi: []
}
fs.readdir("./bilgiler/kisi-bilgiler/", async (err, files) => {
await files.forEach(f => {
dosya.bilgi = fs.readFile(`./bilgiler/kisi-bilgiler/${f}`, handleFile)
});
dosya.sayi = files.length
console.log(dosya.sayi)
console.log(dosya.bilgi)
});