-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake-up.js
77 lines (65 loc) · 2.13 KB
/
make-up.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//Declaration of HTML Tags
const div = document.createElement('div');
div.className="container";
document.body.append(div);
const header = document.querySelector('.header');
header.innerHTML=`<div class="heading">
<img class="tittle-image" src="./title-image.png">
<h2>Beauty Woman</h2>
</div>
`
const load = document.createElement('div');
load.className='load';
load.innerHTML=`
<div id="loading"></div>
<p class="loading-text">"Be your own kind of beautiful"</p>
</div>
`
// Getting Data
async function getData(){
try{
const data = await fetch(
"https://makeup-api.herokuapp.com/api/v1/products.json",
{
method:"GET"
}
);
const products = await data.json();
load.remove();
loadData((products.slice(0,500))); // To speed up my rendering process i made to display 500 datas
}catch (error) {
console.log("Page Not Found : ", error);
}
}
//loadUsers
function loadData(products){
products.forEach(products => {
div.innerHTML+=
`<div class=box>
<img class=product-image src=${products.api_featured_image}">
<div class=product-details>
<h3>${products.name}</h3>
<p class="brand-name">${products.brand}</p>
<div class="buy-now">
<p class="price"><span class="title">Price : $ </span>${products.price} USD </p>
<a class="product-link" href="${products.product_link}">Buy Now</a>
</div>
<div class="description">
<p><span class="title des-title">Description :</span><br>
<span class="des-text">${products.description}</span></p>
</div>
</div>
</div>`;
});
}
//<button class="product-link" onclick="productLink('${products.product_link}')">Product Link</button>
// Product link Redirecting ...
// function productLink(url){
// window.open(url);
// console.log('product Link....',url);
// }
// Calling the Function
const main = document.querySelector(".main")
getData();
main.append(load);
main.append(div);