Let’s say you’ve sent a CSV file in formdata. The key for the CSV file is
myCsvFile.
To read the data as JSON, you’ll have to install csvtojson package and do the following,import csvtojson from "csvtojson"
// your usual code...
const formdata = await request.formdata() // request is simple request object.
const csvFile = formdata.get('myCsvFile')
const json = await csvtojson().fromString(await csvFile.text())Yes, it is that simple!
If you’re using cloudflare workers, I found this article very helpful → https://blog.remeika.us/2023/07/07/parsing-csv-files.html
<script src="https://widget.senja.io/widget/58cb425a-40fe-4e50-985d-8f8631f3c208/platform.js" type="text/javascript" async></script>
<div class="senja-embed" data-id="58cb425a-40fe-4e50-985d-8f8631f3c208" data-mode="shadow" data-lazyload="false" style="display: block; width: 100%;"></div>

