Append a file asynchronously using fs.appendFile
method of fs
module
of node.js
//Name of the file : appendfile-async.js
//Appending a File Asynchronously using nodejs
var fs = require('fs');
new_data = "This data will be appended at the end of the file.";
fs.appendFile('assets/message.txt', new_data , (err) => {
if(err)
throw err;
console.log('The new_content was appended successfully');
});
>node appendfile-async.js
The new_content was appended successfully