Thursday, 16 March 2017

Write in a file using node.js

I want to know if it's possible to write in a file in multiple rows.

i wrote this snippet:

var fs = require('fs');

for(var i=1; i<10; i++){
   fs.writeFile('helloworld.txt', i, function (err) {
    if (err) return console.log(err);
});

But i'm seeing only one row written in the file. how i can write in 10 rows with the for loop?

thanks in advance.



via OiRc

No comments:

Post a Comment