I Have a Simple JSON File With Data and I want to display that data in HTML website following is the JSON file :
[
{
Indice_Name: 'Nasdaq',
price: '13,017.79',
change: '+40.12 (+0.31%)'
},
{
'Indice_Name Name': 'FTSE',
price: '6,729.69',
'change%': '+54.86 (+0.82%)'
},
{
'Indice_Name Name': 'Dow_Jones',
price: '32,787.33',
'change%': '+167.85 (+0.51%)'
},
{
'Indice_Name Name': 'SGX_Nifty',
price: '9.91',
'change%': '-0.02 (-0.20%)'
},
{
'Indice_Name Name': 'Nikkei_225',
price: '29,176.70',
'change%': '+446.82 (+1.56%)'
}
]
Following is My HTML and Javascript File:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="World_Indice_DataDiv"></div>
<script>
fetch('http://127.0.0.1:5500/data/World_Indices_Display.json')
.then(function (response) {
return response.json();
})
.then(function (data) {
appendData(data);
})
.catch(function (err) {
console.log(err);
});
function appendData(data) {
var mainContainer = document.getElementById("World_Indice_DataDiv");
for (var i = 0; i < data.length; i++) {
var div = document.createElement("div");
div.innerHTML = 'Indice Name: ' + data[i].Indice_Name + '\n' + 'Price : ' + data[i].price + '\n' + data[i].change;
mainContainer.appendChild(div);
}
}
</script>
</body>
</html>
When i run this Following piece of code it doesnt show me the expected results:

How Can I Display The JSON Data Correctly?
Indice_Namefield.