This commit is contained in:
Henrik Bygren 2024-03-06 13:13:06 +01:00
parent 560c9a69bd
commit 80f9094a91

View File

@ -63,32 +63,4 @@
<section>Uppgift att lösa!</section>
</footer>
</body>
<script>
function renderNames(names){
let section = document.getElementById('klass');
const ul = document.createElement('ul');
const fragment = document.createDocumentFragment();
names.forEach(student => {
const li = document.createElement('li');
li.innerText = student.name;
fragment.appendChild(li);
});
ul.appendChild(fragment);
section.appendChild(ul)
}
async function getNames(){
const response = await fetch('./api/getNames.js');
const names = await response.json();
renderNames(names);
for(let i = 0; i <names.length; i++){
console.log("namn:" + names[i].name)
}
}
getNames();
</script>
</html>