let url = "https://jsonplaceholder.typicode.com/posts/1/comments"; async function adatlekeres(url) { try{ let response = await fetch(url); if(!response.ok){ throw new Error("HIBA, a response nem OK"); } else{ let data = await response.json(); return data; } } catch{ console.log("Hiba történt!"); } } function createDomElement(element) { let line = document.createElement("div"); line.innerHTML = `ID: ${element.id}, Email: ${element.email}`; eredmeny.appendChild(line); } async function selectSpecifiedData(dataset){ dataset.forEach(element => { if (element.id == 1 || element.id == 3 || element.id == 5){ createDomElement(element); } }); } let eredmeny = document.getElementById("eredmeny"); async function main(){ let adatok = await adatlekeres(url); await selectSpecifiedData(adatok); } main();