-
Notifications
You must be signed in to change notification settings - Fork 149
/
Copy pathcalculate.js
27 lines (27 loc) · 845 Bytes
/
calculate.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
var total = 0;
var order = 0;
function calculate(next){
var opts = {
method: 'GET',
headers: {}
};
fetch('https://shopee.com.my/api/v4/order/get_order_list?limit=5&list_type=3&offset='+next, opts).then(function (response) {
return response.json();
})
.then(function (body) {
var next_offset = body.data.next_offset;
if(next_offset >= 0){
for (let [key, value] of Object.entries(body.data.details_list)) {
var total_temp = value.info_card.final_total / 100000;
total += total_temp;
order++;
console.log(order + ":", "RM " + total_temp + " - ", value.info_card.order_list_cards[0].product_info.item_groups[0].items[0].name);
}
calculate(next_offset);
} else {
console.log('Calculation completed!');
console.log('GRAND TOTAL: RM ' + Math.round(total * 100) / 100);
}
});
}
calculate(0);