I've problem with json file. I've main Object which has another Object and I can't get to that Object.
"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 need to get to "name" property and display it in li
tag. I wrote something like this:
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);
but I only have access to numbers "1", "2", "4" and I don't know what to do next.