diff --git a/UI/assets/js/products.js b/UI/assets/js/products.js index 61f48b3..149bb21 100644 --- a/UI/assets/js/products.js +++ b/UI/assets/js/products.js @@ -1,15 +1,32 @@ -getProducts = () => { - const options = { - headers: new Headers({ +const getProducts = () => { + fetch('https://newstoremanager.herokuapp.com/api/v1/products', { + headers: { 'Content-Type': 'application/json', - 'accessstoken': localStorage.accesstoken, - }), - }; - fetch('https://newstoremanager.herokuapp.com/api/v1/products', options) + accesstoken: localStorage.accesstoken, + }, + }) .then(res => res.json()) .then((data) => { - let output = '

Products

'; - console.log(data); + let output = null; + data.forEach((user) => { + console.log(user.productimage); + output += ` +
+
+ + + + +

${user.productname}

+

${user.price}

+
+ +
+
+ `; + }); + document.getElementById('products-list').innerHTML = output; }); - console.log(localStorage.accesstoken); }; + +/* document.getElementById('products-list').addEventListener('mouseover', getProducts); */ diff --git a/UI/pages/products.html b/UI/pages/products.html index 1ec0bef..f9d4a8d 100644 --- a/UI/pages/products.html +++ b/UI/pages/products.html @@ -13,7 +13,7 @@ - +
-