I'm having trouble with async/await with Node. When I try this:
function Read_Json_File() {
fs.readFile('import.json','utf-8',(err, data) => {
if (err) throw err;
json_data = JSON.parse(data);
return json_data;
});
}
async function run_demo() {
let get_json_file = await Read_Json_File();
console.log(get_json_file);
}
run_demo();
It returns undefined instead of the JSON from the file. Why doesn't it wait for the file reading to finish?