Last active
October 17, 2017 19:14
-
-
Save codejockie/29424714af1096bcf1a440ee4c451fd1 to your computer and use it in GitHub Desktop.
write/append to file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import fs from 'fs'; | |
| const file = file.txt; | |
| fs.writeFile(file,'Some text to write.', (error) => { | |
| if(error) { | |
| console.error(error); | |
| } | |
| console.log('Written!'); | |
| }); | |
| fs.appendFile(file,'Some more text to append.', (error) => { | |
| if(error) { | |
| console.error(error); | |
| } | |
| console.log('Appended!'); | |
| }); | |
| fs.appendFile('log.txt', 'new data', (error) => { | |
| if (error) { | |
| // Failed: append error | |
| } else { | |
| // Success: append success | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment