Hello
var Observable = require("FuseJS/Observable");
var Storage = require("FuseJS/Storage");
var note_Json = ("note_Json.json");
var savedData = Observable("Loading...");
var note = Observable("");
Storage.read(note_Json).then(
function(content) {
// body...
var data = JSON.parse(content);
savedData.value = "Last saved: " + data.note;
},
function(error) {
// body...
savedData.value = "Can't find any notes saved";
}
);
function saveData() {
// body...
var storeObj = {note: note.value};
Storage.write(note_Json, JSON.stringify(storeObj));
savedData.value = note.value;
}
module.exports = {
saveData : saveData,
savedData : savedData,
note : note,
}
this is my code to save a text to a json file. What if I wanted to save new lines to this file. e.g
first text saved was
Tom
and later when the user enters Jerry it should append “Jerry” to the JSON file. e.g
Tom
Jerry