Any way to easily fix this JSON code in the email and make it show properly?
MOD EDIT: Sensitive data removed
Here is my site Read-Only: Webflow - Ayia Napa & Protaras City Pass
Any way to easily fix this JSON code in the email and make it show properly?
MOD EDIT: Sensitive data removed
Here is my site Read-Only: Webflow - Ayia Napa & Protaras City Pass
hi @kyriacosgeo you need to destructure your returned JSON and send it as HTML. I can’t help with “how to in WF” as I’m using in my non WF project nodemailer lib.
Here is a simple example of basic principle how it can be done. How your HTML will look like is up to you this example use table
const jsonData = {
"date_valid_from": "2024-07-10",
"pass_holders": [
{
"first_name": "Andreas",
"last_name": "Avraam",
"dob": "2002-07-02",
"pass_type": "5 Day Pass",
"identifier": "5-day-pass-holder-1",
"date_valid_until": "2024-07-15"
}
]
};
const jsonDataToHTML = (data) => {
let html = "<table border='1'>";
Object.keys(data).forEach(key => {
if (Array.isArray(data[key])) {
html += "<tr><td>" + key + "</td><td></td></tr>";
data[key].forEach(item => {
html += "<tr>";
Object.values(item).forEach(value => {
html += "<td>" + value + "</td>";
});
html += "</tr>";
});
} else {
html += "<tr><td>" + key + "</td><td>" + data[key] + "</td></tr>";
}
});
html += "</table>";
return html;
};
const htmlTable = jsonDataToHTML(jsonData);