I have an Angular 6 application that lists a Json object.
I want to put a field where the user enters his mail and automatically send that Json object converted to Csv as an attachment to his mail
I did this but I think that the matter is not there
const json = [
{
titulo: 'titulo 1',
descripcion: 'descripcion 1',
precio: 1431
},
{
titulo: 'titulo 2',
descripcion: 'descripcion 2',
precio: 1431
},
{
titulo: 'titulo 3',
descripcion: 'descripcion 1',
precio: 1431
},
];
const replacer = (key, value) => value === null ? '' : value;
const header = Object.keys(json[0]);
let csv = json.map(row => header.map(fieldName => JSON.stringify(row[fieldName], replacer)).join(','));
csv.unshift(header.join(','));
csv = csv.join('\r\n');
console.log(csv);
What it shows me in console is this
But now how do I convert it to a CSV file and attach it to an email?
Or some other solution
I'm working with Angular and PHP
Thanks:)