-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiPadmini.js
53 lines (43 loc) · 1.81 KB
/
iPadmini.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
(function () {
"use strict";
window.onload = function(){
document.getElementById("submit").addEventListener("click", sub)
//fetch price from amazon.
fetch("https://amazon-price1.p.rapidapi.com/search?marketplace=US&keywords=2019%20Apple%20iPad%20Mini%20(Wi-Fi%2C%2064GB)%20-%20Gold", {
"method": "GET",
"headers": {
"x-rapidapi-key": "ede3e37a32msh7ee72e454d92ddcp170afcjsn8d76ea6ebec4",
"x-rapidapi-host": "amazon-price1.p.rapidapi.com"
}
})
.then(response => response.json())
.then(displayData)
.catch(err => {
console.error(err);
});
function displayData(response){
document.getElementById('item-desc1').textContent = response[0].title;
document.getElementById('amazon1').textContent = response[0].price;
}
// fetch price from Best Buy
fetch("https://bestbuy-products.p.rapidapi.com/product?url=https%3A%2F%2Fwww.bestbuy.com%2Fsite%2Fapple-7-9-inch-ipad-mini-5th-generation-with-wi-fi-64gb-gold%2F5497900.p%3FskuId%3D5497900&sku=5748618", {
"method": "GET",
"headers": {
"x-rapidapi-key": "9eabc92e42mshcbe2969f600a38bp1162f5jsn52a0ef3d2cdf",
"x-rapidapi-host": "bestbuy-products.p.rapidapi.com"
}
})
.then(response => response.json())
.then(displayData1)
.catch(err => {
console.error(err);
});
function displayData1(response){
document.getElementById('bestbuy').textContent = response.prices.currency+response.prices.current_price;
}
}
//Subscribe button action
function sub(){
alert("Thank you for subscription!")
}
})();