Answers for "nodejs add to txt file"

2

Append text into a file nodejs

const fs = require('fs');

fs.appendFile('message.txt', 'data to append', function (err) {
  if (err) throw err;
  console.log('Saved!');
});

If message.txt doesnt exist, It will gonna create that too
Posted by: Guest on March-16-2021
3

Append text into a file nodejs

Synchronously

const fs = require('fs');

fs.appendFileSync('message.txt', 'data to append');
Posted by: Guest on March-16-2021
0

save text to file nodejs

fs = require('fs');
fs.writeFile(filename, data, [encoding], [callback])
Posted by: Guest on July-18-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language