I have a simple blog website that has a submit form and the data from that is posted on the screen, and sent as an object to my node js server. Since I want all of my existing posts to stay on the website(after refresh) I need to keep my data in JSON. I have been stuck on this part all day and can't figure it out. Here is where I think the error/ misunderstanding is.
app.post('/api', (req, res) => {
    const data = req.body;
    const words = JSON.stringify(data, null, 2);
    res.send('success')
    fs.writeFile('data.json', words, finished);
    function finished(err) {
    console.log('all set')
        }
    console.log(words) 
   }
);
What I have currently adds the data to the 'data.json' file, however whenever I try to add another post on the page, the data in the JSON file only keeps the most recent submitted data. I am a new programmer so I apologize if it is something obvious. Thanks in advance and if you need more information just ask!
