I have this inside an Express.js-like (it's actually Next.js version of something like Express.js) function. The url is a url that ends in .csv, so it is a CSV file download. I'm trying to fetch the CSV and stream the data through the csv-parser library (so I don't have to persist the file) and then finally into an array (I've omitted some of this code, as it is relevant).
export default async (req: NextApiRequest, res: NextApiResponse) => {
...
const response: Response = await fetch(url)
try {
response.body.pipe(parser())
.on('data', callback...)
} catch {
error handling...
}
}
It all works the way I want it, but when I go to build my app I get this error on the response.body.pipe part.
Type error: Property 'pipe' does not exist on type 'ReadableStream<Uint8Array>'.
Hope this is enough context & makes sense. Could anyone advise on how to address this?
I parsed NextApiRequest body like this:
const d = await req.body?.getReader().read();
console.log(d?.value?.toString());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With