I can't get JSON to display what are my missing?

I'm developing a JSON webpage that would basically display all data returned by the server. However, it doesn't work. I tried everything taht I could think of, but it still doesn't work. Please help. I didn't receave any error or warnings. The webpage is just nothingness. The data should be display in a tag but it is not.

let arrayForData = [];

function showFamilyInfo() {
  fetch('users.json')
    .then(function(response) {
      response.json()
        .then(function(data) {
          let parseData = data;
          console.log(parseData);
          parseData.forEach(function(element) {
            for (let i in parseData[element]) {
              arrayForData.push(`'
<p>
${element[i]}: ${i.FirstName}
${element[i]}: ${i.LastName}
${element[i]}: ${i.Age}
${element[i]}:${i.Gender}
</p>
'`);
            }
          });
          document.getElementById('demo').innerHTML = arrayForData.join();
        })
        .catch(function(error) {
          document.getElementById('demo').innerHTML = error;
        });
    });
}
console.log(arrayForData);
<span id="demo">
</span>
<button onclick="showFamilyInfo()">
Show Family Info
    </button>

It doesn't seems that the JS regonize the element[i] object. What are the problems with my code?



from Recent Questions - Stack Overflow https://ift.tt/3sWDQBL
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation