node.js output to text file code example
Example 1: how to right plain text format file in node js
var fs = require('fs')
var logger = fs.createWriteStream('log.txt', {
flags: 'a'
})
logger.write('some data')
logger.write('more data')
logger.write('and more')
Example 2: writefile in node js
const fs = require('fs');
let writeStream = fs.createWriteStream('secret.txt');
writeStream.write('aef35ghhjdk74hja83ksnfjk888sfsf', 'base64');
writeStream.on('finish', () => {
console.log('wrote all data to file');
});
writeStream.end();