From d2db54f04c1ccb4fe13d134aa7cf7d466b47382e Mon Sep 17 00:00:00 2001 From: aaron-kane-w Date: Tue, 26 May 2020 19:51:39 -0500 Subject: [PATCH 1/2] initial change --- public/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/index.html b/public/index.html index f89dd7a..8e7f009 100644 --- a/public/index.html +++ b/public/index.html @@ -3,7 +3,7 @@ - My Store + Aaron Williamson From 57df89a3da61bfc89cd0bcec23db09b32dc7baa5 Mon Sep 17 00:00:00 2001 From: aaron-kane-w Date: Tue, 26 May 2020 20:36:41 -0500 Subject: [PATCH 2/2] fetch class assignment complete --- public/index.html | 16 +++++++++++++++- public/index.js | 25 +++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/public/index.html b/public/index.html index 8e7f009..e06a726 100644 --- a/public/index.html +++ b/public/index.html @@ -5,9 +5,23 @@ Aaron Williamson - + +
+

Products

+
+
+
    +
    diff --git a/public/index.js b/public/index.js index 6515a73..faf5751 100644 --- a/public/index.js +++ b/public/index.js @@ -1,2 +1,23 @@ -//stuff -//more stuff \ No newline at end of file +const url = 'https://my-json-server.typicode.com/jubs16/Products/Products' + + +function getPosts() { + fetch(url) + .then(response => response.json()) + .then((posts) => { + return posts.forEach(function(x) { + const ul = document.getElementById('fetch') + + let img = document.createElement('img') + img.src = `${x.imgUrl}` + + let li = document.createElement('li') + li.innerHTML = `${x.name} $${x.price}` + + ul.appendChild(li) + ul.appendChild(img) + }) + + }) +} +getPosts() \ No newline at end of file