I have a JSON object with a key:value pair named callRoot. Some examples of values for this pair are @S, @C, and @W. There are multiple objects that share the same value and I want to create an HTML table head row at the beginning of each group and repeat it for each data set.
Latest Update
Here's a Fetch API function for accessing remote API data:
const fetchData = function() {
const apiKey = "";
const request = `https://apiurl.com`;
fetch(request)
.then(response => response.json())
.then((data) => foo(data))
.catch(error => {
console.log(error);
});
}
fetchData();
New Update
for (let i of filtered[property]) {
const tr = document.createElement('tr');
tblBody.appendChild(tr);
data.forEach(element => {
console.log(element);
});
Sample JSON data provided below:
const data = [
{
"symbol": {
"description": "SOYBEANS January 2022"
},
// more data...
];
Code snippet:
// Create empty arrays for each callRoot grouping
// further implementation is similar to above code block...
Example structure of the HTML table:
<table>
<tbody>
<tr>
<th colspan="9">SOYBEANS</th>
</tr>
// more table rows...
</tbody>
// repeated structure for other groups...
</table>