I'm reading csv file and do some processing but with this processing the other method get called and I'm getting error for that. so I want to execute return method after all process done. please help. thanks.
async function createcsv(data){
try{
const stream = Readable.from(data.buffer)
const data1 = stream
.pipe(csv())
.on("data", async (data) => results.push(data))
.on("end", async () => {
//doing some process
}
return {
status:"success"
message:"created csv"
file:filename
}
}catch(err){
console.log(err)
}
}
so the return method execute early and I didn't get file name which I'm processing inside stream so I want execute return method at the end and also get the file name because I'me processing thousand of csv file data. please help