Within a function resembling Express.js in Next.js, I am working on fetching a CSV file with a URL that ends in .csv. Using the csv-parser library to stream the data without persisting the file and transform it into an array. Here is an excerpt of the code:
export default async (req: NextApiRequest, res: NextApiResponse) => {
...
const response: Response = await fetch(url)
try {
response.body.pipe(parser())
.on('data', callback...)
} catch {
error handling...
}
}
Although my code functions as expected, I encounter an error related to the response.body.pipe when building the app:
Type error: Property 'pipe' does not exist on type 'ReadableStream<Uint8Array>'.
Providing this context, is there a solution or suggestion to resolve this issue?