-
Notifications
You must be signed in to change notification settings - Fork 0
/
writefileinnode.js
29 lines (20 loc) · 907 Bytes
/
writefileinnode.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const fs = require('fs');
var content = ' This is some content that I want to write to a file.';
const contentTwo = "Wazza zap ! "
const writeFile = async () => {
try {
await fs.writeFile('./my-file.txt', content, ( err, content ) => {
const writeSecondFile = async () => {
await fs.writeFile('./myFile#2.txt', contentTwo, (err, contentTwo) =>
{
var content = 'This is some content that I want to write to a file.';
console.log("Successfully wrote: " + `${content}` + " to the console. ")
} )} ; writeSecondFile();
});
console.log('File written successfully! the content : ' + contentTwo + " Was written in the file ! " );
} catch (err) {
console.log('Error writing file:', err);
}
};
writeFile();
console.log(" I wrote the file but this command should come first ! ")