Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const data = records.map(record => {
const { author, ...recordForExport } = record; // omit author
recordForExport.author_name = author.name;
recordForExport.post_title = posts[record.post_id].title;
return recordForExport;
});
const headers = [
'id',
'author_name',
'post_id',
'post_title',
'created_at',
'body',
];
jsonExport(data, { headers }, (error, csv) => {
if (error) {
console.error(error);
}
downloadCSV(csv, 'comments');
});
});
.then(({ data }) =>
exporter
? exporter(
data,
fetchRelatedRecords(dataProvider),
dataProvider
)
: jsonExport(data, (err, csv) =>
downloadCSV(csv, resource)
)
)
const exporter = posts => {
const data = posts.map(post => ({
...post,
backlinks: lodashGet(post, 'backlinks', []).map(
backlink => backlink.url
),
}));
jsonExport(data, (err, csv) => downloadCSV(csv, 'posts'));
};