I have an API I'm trying to fetch and display data from. The data I want to access is in the 'equipments' array as shown below.
I'm trying to loop through the 'equipments' array for each item but I'm having trouble displaying the data. I believe I'm either not accessing it properly, or not including another loop somewhere.
Here's what I have so far:
// Fetch Data
function getData() {
fetch(url)
.then((res) => res.json())
.then((data) => {
let output = "";
data.groups.equipments.forEach(function(product) {
output += `
<div class="card">
<img src=${product.photos.text} alt=${product.model} />
<h3>${product.year} ${product.manufacturer} ${product.model}</h3>
<p>${product.hours} hours</p>
<a href='https://used.battlefieldequipment.ca/en/${product["group-code"]}/${product.equipments["serial-number"]}' class="btn btn-primary">View Details</a>
</div>
`;
});
dataOutput.innerHTML = output;
})
}
getData();
Any idea what I need to do in order to get this working?

data.groupsis an array, too!