Created
December 31, 2019 10:32
-
-
Save Haosvit/c59e074b99a2ec643abd657858c7be40 to your computer and use it in GitHub Desktop.
node write file javascript
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
function writeFile(fileName, data, indent = 2) { | |
require('fs').writeFile(`${fileName}`, JSON.stringify(data, '', indent), (err) => { | |
if (err) { | |
return console.log(err); | |
} | |
console.log(`Done "${fileName}".`); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment