Created
April 12, 2022 12:29
-
-
Save luisoos/493231b7c73eedb07a7b62b03972cb02 to your computer and use it in GitHub Desktop.
Node.js program that saves data to an external json file
This file contains 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
var fs = require('fs'); | |
var obj = { | |
date: date, | |
speed: speed | |
} | |
data.push(obj) | |
fs.writeFile ("data.json", JSON.stringify(data, null, 4), function(err) { | |
if (err) throw err; | |
console.log('Data saved.'); | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment