zemirco / json2csv

Convert json to csv with column titles
http://zemirco.github.io/json2csv
MIT License
2.72k stars 363 forks source link

not working using Sequelize #206

Closed alziqziq closed 7 years ago

alziqziq commented 7 years ago

var fields = ['car', 'price'];

User.all().then((response) => { var data = json2csv({data : response, fields : fields}); console.log(data); // Output data : // "car","price" //, //, });

whats wrong?

knownasilya commented 7 years ago

The response is probably not what you think it is. Put a console log there and paste the result here.

alziqziq commented 7 years ago

the problem is because the column name is different from the database column name.

how do I custom the column names?

knownasilya commented 7 years ago

See the documentation for the fields parameter here https://github.com/zemirco/json2csv/blob/master/README.md#example-fields-option