Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1016 from parameter1/l
Browse files Browse the repository at this point in the history
Fix json.data array
  • Loading branch information
brandonbk authored Nov 16, 2024
2 parents e0f2b08 + b3ba9ff commit 54a12d0
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions packages/marko-newsletters-native-x/utils/fetch-email-ad.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,21 @@ module.exports = async ({
throw err;
}
const regex = /^\s+<p/;
if (Array.isArray(json.data)) {
const results = json.data.map((node) => ({
...node,
creative: {
...node.creative,
...(node.creative.teaser && !regex.test(node.creative.teaser) && {
teaser: `<p>${node.creative.teaser}</p>`,
if (json.data && Array.isArray(json.data) && json.data.length) {
const results = {
...json,
data: json.data.map((node) => ({
...node,
...(node.creative && {
creative: {
...node.creative,
...(node.creative.teaser && !regex.test(node.creative.teaser) && {
teaser: `<p>${node.creative.teaser}</p>`,
}),
},
}),
},
}));
})),
};
return results;
}
if (json.data && json.data.creative) {
Expand Down

0 comments on commit 54a12d0

Please sign in to comment.