From adb084d6762ef7e2dbcd31e0e116d67ba306cda1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kov=C3=A1cs=20Rudolf?= Date: Wed, 4 Nov 2026 10:54:51 +0100 Subject: [PATCH] =?UTF-8?q?K=C3=A9pek=20fetchel=C3=A9se,=20megjelen=C3=ADt?= =?UTF-8?q?=C3=A9se?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rest2/fetch.js | 27 +++++++++++++++++++++++++++ rest2/index.html | 17 +++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 rest2/fetch.js create mode 100644 rest2/index.html diff --git a/rest2/fetch.js b/rest2/fetch.js new file mode 100644 index 0000000..a32a68f --- /dev/null +++ b/rest2/fetch.js @@ -0,0 +1,27 @@ +let root=document.getElementById('root'); + +let kontener=document.createElement('div'); +//kontener.setAttribute('class','flex flex-row flex-wrap items-center justify-center bg-sky-200'); +kontener.setAttribute('class','grid lg:grid-cols-4 md:grid-cols-2 sm:grid-cols-1 justify-items-center bg-sky-200'); + +fetch('https://jsonplaceholder.typicode.com/photos') +.then(res=>res.json()) +.then(adat=>{ + //console.log(adat) + adat.forEach(kep => { + let kepkontener=document.createElement('div'); + kepkontener.setAttribute('class','flex flex-col items-center justify-center rounded-xl w-96 bg-sky-400 m-2 p-2'); + let title=document.createElement('p'); + title.setAttribute('class','text-2xl text-center text-sky-800'); + title.textContent=kep.title; + let image=document.createElement('img'); + image.setAttribute('class','rounded-xl w-96') + image.src=kep.url; + kepkontener.appendChild(image); + kepkontener.appendChild(title); + kontener.appendChild(kepkontener); + }); +}) +.catch(err=>alert(err)); + +root.appendChild(kontener); \ No newline at end of file diff --git a/rest2/index.html b/rest2/index.html new file mode 100644 index 0000000..391646a --- /dev/null +++ b/rest2/index.html @@ -0,0 +1,17 @@ + + + + + + + + Fetch használata + + +

Fetch használata

+
+ +
+ + + \ No newline at end of file