I'm using https://www.npmjs.com/package/react-csv library to export some data by generating a csv file. The above mentioned library supports the following data format
const csvData = [
["firstname", "lastname", "email"],
["Ahmed", "Tomi", "[email protected]"],
["Raed", "Labes", "[email protected]"],
["Yezzi", "Min l3b", "[email protected]"]
];
The data i want to export is getting from a API response. I'm mapping my data array to create a data structure as above.
const csvData = [
["A", "B", "C", "D", "E", "F", "G", "H"],
transaction.transactionData && transaction.transactionData.map((item, key) => {
return (
[item.A, item.B, item.C, item.D, item.E, item.F, item.G, item.H]
)
})
]
But this won't output the structure i want (the one i showed you in the beginning). How can i map my data so it takes the required structure.
i console logged csvData and it looks like this
