I'm struggling with a JSON file. I have a main object that contains nested objects, but I can't seem to access them.
"vendors": {
"1": {
"id": 1,
"name": "Exponential Interactive, Inc d/b/a VDX.tv",
"policyUrl": "https://vdx.tv/privacy/",
},
"2": {
"id": 2,
"name": "Captify Technologies Limited",
"policyUrl": "https://www.captify.co.uk/privacy-policy-opt/",
},
"4": {
"id": 4,
"name": "Roq.ad Inc.",
"policyUrl": "https://www.roq.ad/privacy-policy",
},
I am trying to access the "name" property and display it in a li
tag. Here is my current code:
fetch("jsonpage")
.then((res) => res.json())
.then((data) => {
for (const number of Object.keys(data.vendors)) {
let newVendor = document.createElement("li");
newVendor.textContent = number;
ulList.appendChild(newVendor);
}
})
.catch(console.error);
However, I am only able to access the numbers "1", "2", and "4", and I'm not sure what to do next.