JSFiddle - React, Tailwind, and code Playground

by lasha

HTML

<h1>
Hello world
</h1>
<p>This is the todo app! Welcome.</p>

<ul>
</ul>

JavaScript

fetch('https://api.github.com/users/Lasha/repos')
  .then(response => response.json())
  .then(data => renderContent(data));

/* let itemsFromDatabase = ['Item 1', 'Item 2', 'Item 3', 'Item 4', 'Item 5']; */

/* function getItemsFromDatabase() {
  let data = itemsFromDatabase;
  renderContent(data);
} */

const listElement = document.querySelector('ul');
function renderContent(data) {
	var html = '';
	data.forEach(repo => html += `<li><a target="new" href="${repo.html_url}">${repo.name}</a></li>`);
  
  renderRepoItems(html);
}

function renderRepoItems(html) {
	listElement.innerHTML = html;
}


/* function renderContent(data) {
  var html = "";
  data.forEach(item => html += `<li>${item}</li>`)
  console.log(html)
  
  const listElement = document.querySelector('ul');
  listElement.innerHTML = html
  console.log(listElement)
}
 */
/* getItemsFromDatabase() */