Not a problem!
If your original payload query1.data
looks like this (just guessing based on the screenshot)
[
{
id: 1,
photo: null,
created: "Dec-09-2024",
customParams: [
{ name: "name", value: "Some Name" },
{ name: "phone", value: "555-5555" },
{ name: "email", value: "email@gmail.com" },
],
},
{
id: 2,
photo: "image.jpg",
created: "Jan-10-2025",
customParams: [
{ name: "name", value: "Another Name" },
{ name: "phone", value: "123-4567" },
],
},
...
]
you can write a transformer like this:
return {{ query1.data }}.map((obj) => {
if (Array.isArray(obj.customParams)) {
const { customParams, ...rest } = obj;
const flattened = Object.fromEntries(
customParams.map((param) => [param.name, param.value])
);
return { ...rest, ...flattened };
}
return obj;
});
This should return a result like this:
[
{
"id": 1,
"photo": null,
"created": "Dec-09-2024",
"name": "Some Name",
"phone": "555-5555",
"email": "email@gmail.com"
},
{
"id": 2,
"photo": "image.jpg",
"created": "Jan-10-2025",
"name": "Another Name",
"phone": "123-4567"
}
]
You can then hook up your table directly to that transformer.