I am trying to download a CSV file from the below data:
import { CSVLink } from "react-csv";
headers = [
{ label: "First Name", key: "firstname" },
{ label: "Last Name", key: "lastname" },
{ label: "Email", key: "email" }
];
data = [
{ firstname: "Ahmed", lastname: "Tomi", email: "ah@smthing.co.com" },
{ firstname: "Raed", lastname: "Labes", email: "rl@smthing.co.com" },
{ firstname: "Yezzi", lastname: "Min l3b", email: "ymin@cocococo.com" }
];
<CSVLink data={data} headers={headers}>
Download me
</CSVLink>;
When I click the Download me link, I get a file with .csv extension, but it contains the HTML of that page. If I use CSVDownload the correct CSV file is downloaded.
I am using Next.js. What additional thing should I add to CSVLink so I get the correct CSV data?