Writing a file asynchronously using fs.writeFile
method of fs
module
of node.js
//Name of the file : writefile-async.js
//Writing a File Asynchronously using nodejs
var fs = require('fs');
var content= "this is the content in the file";
fs.writeFile('assets/message.txt', content , (err) => {
if (err)
throw err;
console.log('It\'s saved!');
});
>node writefile-async.js
It's saved!