Skip to content

Instantly share code, notes, and snippets.

@luisoos
Created April 12, 2022 12:29
Show Gist options
  • Save luisoos/493231b7c73eedb07a7b62b03972cb02 to your computer and use it in GitHub Desktop.
Save luisoos/493231b7c73eedb07a7b62b03972cb02 to your computer and use it in GitHub Desktop.
Node.js program that saves data to an external json file
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