-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
42 lines (32 loc) · 953 Bytes
/
index.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
const axios = require('axios');
const { insertDocument, findDocuments } = require('./utilities/datastore');
const stores = [
{
id: 37213,
name: 'Riyadh'
},
{
id: 172911,
name: 'Faris Perfumes'
}
]
const Headers = {
'Content-Type': 'application/json',
'Store-Id': stores[1].id,
};
async function getProducts() {
const response = await axios.get('https://api.zid.sa/v1/products/', { headers: Headers });
return {products: response.data.results};
}
async function getCategories() {
const response = await axios.get('https://api.zid.sa/v1/products/categories/', { headers: Headers });
return {categories: response.data.results};
}
async function main() {
const products = await getProducts();
// console.log(products.products[0]);
const categories = await getCategories();
console.log(categories.categories[0]);
//insertDocument(products);
}
main();