Quote:
async function run() { ... }
run();
console.log(data);
You're logging the data
before the function has finished executing.
async function - JavaScript | MDN[
^]
You need to wait for the function to finish before you can access its output. The simplest way to do that is to move your
console.log
line inside the
async
function:
async function run(){
let dat = await convertCsv(csvFilePath);
data.push(dat);
console.log(data);
return dat;
}
run();