Async Code in Node.js: Callbacks and Promises
You trigger a file read in a Node.js app and immediately log the result:
const fs = require('fs');
let data;
fs.readFile('file.txt', 'utf-8', (err, result) => {
data = result;
});
console.log(data
mohammadaman.hashnode.dev4 min read