I have a function will send all the images that located inside the "samples" folder to extractImage function, then, the extractImage function will call 3rd party API to perform its operation. But when I try to console.log(arr), it seem like didn't even be called. I think I have did something wrong to handling the async, could someone help me to have a look. I have quick new to JavaScript.
let arr = [];
await fs.readdir("samples", async (err, files) => {
console.log(files);
files.map(async (val) => {
console.log(val);
let tt = await extractImage(val);
return arr.push(tt);
});
});
fs.writeFileSync("final.json", "s");
console.log(arr);
console.log("tt");
const files = await readdir(path);