Skip to content

Instantly share code, notes, and snippets.

@krsntn
Created October 7, 2021 09:02
Show Gist options
  • Select an option

  • Save krsntn/797d0a47d147e41a7c0d5332bd706747 to your computer and use it in GitHub Desktop.

Select an option

Save krsntn/797d0a47d147e41a7c0d5332bd706747 to your computer and use it in GitHub Desktop.
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?list_type=3&offset=' +
next,
opts
)
.then(function (response) {
return response.json();
})
.then(function (body) {
let next_offset = body.data.next_offset;
if (next_offset >= 0) {
for (let item of body.data.details_list) {
let total_temp = item.info_card.final_total;
total += total_temp;
order++;
const { ctime, description } = item.shipping.tracking_info;
const dateTime = new Date(ctime * 1000);
console.log(
`${order}: RM ${total_temp / 100000} - ${
item.info_card.order_list_cards[0].items[0].name
}\n${
dateTime.getFullYear() +
'/' +
(dateTime.getMonth() + 1) +
'/' +
dateTime.getDate()
} - ${description}`
);
}
calculate(next_offset);
} else {
console.log('GRAND TOTAL: RM ' + total / 100000);
}
});
}
calculate(0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment