JSFiddle - React, Tailwind, and code Playground
HTML
<ul class="list">
</ul>
JavaScript
var list = document.querySelector('.list'),
listitem = document.querySelectorAll('.list-item'),
content;
function showItems() {
let url = 'https://swapi.co/api/people';
fetch(url)
.then(function(response) {
return response.json();
}).then(function(data) {
let results = data.results;
results.forEach(item => {
content = `<li class="list-item"><a href="#">${item.name}</a></li>`;
list.innerHTML += content;
});
//This displays the entire content
console.log(list);
//This doens't find the child elements
console.log(listitem);
}).catch(function(err) {
console.log(err);
});
}
showItems();