I'm struggling to push a new object into an array. At the moment the code below seems to be simply overwriting a single object. I can see the data I want to push to the array going through the console but it's just not storing a new object. Any ideas?
fs.readFile('check.json', function (err, check) {
if (err) throw err;
var newData = JSON.parse(check);
var tempData =[];
for (var index=0; index<newData.length; index++){
tempData.push(newData);
}
tempData = newData;
});
tempDataarray by assigning it withnewDatain the last line