diff --git a/app.html b/app.html index 06cc807..3aee824 100644 --- a/app.html +++ b/app.html @@ -1,32 +1,26 @@ - - - Gallery - - -
-

- Gallery -

-

Share all your photos right here

-
- -
- +
+ + - - - - - + + + + + \ No newline at end of file diff --git a/app.js b/app.js index 0da6bde..4adceae 100644 --- a/app.js +++ b/app.js @@ -13,3 +13,34 @@ fetch('url').then(ResolveFuntion, RejectFuntion) */ const app = document.querySelector("#app"); +let divR = document.createElement("div"); +divR.className = "row"; +app.appendChild(divR); + +fetch(URL) + .then((response) => { + if (response.status >= 200 && response.status <= 299) { + return response.json(); + } else { + throw new Error( + `Encountered something unexpected: ${response.status} ${response.statusText}` + ); + } + }) + .then((data) => { + data.forEach(item => { + let divC = document.createElement("div"); + divC.className = "column"; + let img = document.createElement("img"); + img.src = item.url; + let p = document.createElement("p"); + p.textContent = item.author + " - " + item.title; + divC.appendChild(img); + divC.appendChild(p); + divR.appendChild(divC); + }); + }) + .catch((error) => { + // Handle the error + console.log(error); + }); \ No newline at end of file