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