Basic HTML: How to Read JSON of Data – Where Do I Start? or Struggling with Basic HTML – How to Read

18 Replies, 457 Views

Dude, same struggle when I started! HTML is just markup—no logic. You *have* to use JS.

Try this:
```javascript
// Assuming you have a JSON file named 'data.json'
fetch('data.json')
.then(res => res.json())
.then(data => {
let output = '';
data.forEach(item => {
output += `<p>${item.name}</p>`;
});
document.body.innerHTML = output;
});
```

It’s a bit more advanced but shows how to loop through JSON.

Messages In This Thread



Users browsing this thread: 1 Guest(s)