I am relatively new to this and haven't quite got my head round how this all works...
Basically I am using the csvtojson function to convert a csv file into json. This works fine and outputs the json array to the console.log.
After performing this action I want to take the json array returned and do some extra things to it e.g outputting to a file.
My question is how do use the array outside of the function where it is created, Alternatively should I be writing the code within the function?
This is my code:
const csvFilePath='./test.csv'
const csv=require('csvtojson')
csv()
.fromFile(csvFilePath)
.then((jsonObj)=>{
console.log(jsonObj);
//should I write code here
});
console.log(jsonObj);
//This returns jsonObj is not defined
//how do I/Can I read jsonObj here
Can someone help me understand what I need to do here please?