From 9b16d6281495610f5fa93ba19f42d09055dc1ec8 Mon Sep 17 00:00:00 2001 From: Aman Kumar Date: Thu, 5 Oct 2023 16:39:51 +0530 Subject: [PATCH] refactor: sanitize taxonomies & term --- .../contentstack-export-to-csv/src/util/index.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/packages/contentstack-export-to-csv/src/util/index.js b/packages/contentstack-export-to-csv/src/util/index.js index 8eb09fc902..c9132be470 100644 --- a/packages/contentstack-export-to-csv/src/util/index.js +++ b/packages/contentstack-export-to-csv/src/util/index.js @@ -787,13 +787,11 @@ async function apiRequestHandler(payload, skip, limit) { function formatTaxonomiesData(taxonomies) { if (taxonomies?.length) { const formattedTaxonomies = taxonomies.map((taxonomy) => { - let obj = { + return sanitizeData({ 'Taxonomy UID': taxonomy.uid, Name: taxonomy.name, Description: taxonomy.description, - }; - obj = sanitizeData(obj); - return obj; + }); }); return formattedTaxonomies; } @@ -808,14 +806,12 @@ function formatTaxonomiesData(taxonomies) { function formatTermsOfTaxonomyData(terms, taxonomyUID) { if (terms?.length) { const formattedTerms = terms.map((term) => { - let obj = { + return sanitizeData({ 'Taxonomy UID': taxonomyUID, UID: term.uid, Name: term.name, 'Parent UID': term.parent_uid, - } - obj = sanitizeData(obj); - return obj; + }); }); return formattedTerms; } @@ -864,5 +860,5 @@ module.exports = { formatTaxonomiesData, formatTermsOfTaxonomyData, getTaxonomy, - getStacks + getStacks, };