Merging Two Data Sets into One Table
Using JavaScript to Merge Two Data Sets
- Create a dataflow.
- In [action1], retrieve data from the first data source.
- In [action2], retrieve data from the second data source.
- In [action3], select
JavaScript
and enter the following code:
const action1 = {{ action1.data }}
const action2 = {{ action2.data }}
const mergedData = []
for (let i = 0; i < action1.length; i++) {
const id = action1[i].id
const data1 = action1[i]
const data2 = action2.find(d => d.id === id)
if (data2) {
mergedData.push({ ...data1, ...data2 })
}
}
return mergedData
- Place a [Table].
- In [Data], enter
{{ dataflow1.data }}
.