Closed johnothetree closed 5 years ago
Hi @johnothetree , thanks for the link to the repo, that's really helpful to understand what's happening.
csv-writer
is overwriting only for the first POST request, because it's initialised only once at the beginning of the app. If you want it to overwrite every time you make the POST request, you can move the createCsvWriter
call inside of .post
callback function.
Also, append: false
is a default behaviour, so you can safely omit it 😉
@ryu1kn thanks for the help, didn't think about the initialization causing what I was seeing, but that makes sense. Thanks for the help!
Working on a personal project for maintaining an album-of-the-year list, and using csv-writer in NodeJS to maintain a csv that holds all the values (repo here). The first time I do a POST call, it overwrites the CSV correctly, but if I call it more than once, it instead appends the consecutive post calls to the existing CSV instead of overwriting as intended.