Hi!
By asynchronously
const fs = require("fs");
const path = require("path");
const fileUrl = path.join(__dirname, "test.txt");
fs.readFile(fileUrl,(err,data)=>{
console.log("fileData: ",data)
});
By synchronously
const fs = require("fs");
const path = require("path");
const fileUrl = path.join(__dirname, "test.txt");
const fileData = fs.readFileSync(fileUrl);
console.log(fileData )
Top comments (1)
Hey, that was a nice read, you got my follow, keep writing 😉