Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fs = require('fs');
- logToFile = function(fileName, objectToLog) {
- jsonText = JSON.stringify(objectToLog, null, 't');
- fs.writeFileSync(fileName, jsonText, 'utf8');
- }
- sampleData = { name: 'Batman', city: 'Gotham' };
- logToFile('log.txt', sampleData);
Add Comment
Please, Sign In to add comment