I need to append my JSON data to an array inside a JSON file. It is appending successfully. However, it does not append inside of the Brackets in the JSON file
Here is my NODE
if (req.method == 'POST') {
req.on('data', function (chunk) {
fs.writeFile("comments-data.json", chunk, {'flag':'a'}, function(err) {
if(err) {
return console.log(err);
}
console.log("The file was saved!");
})
});
res.end('{"msg": "success"}');
};
How can i tell it to just append inside of the brackets?