Skip to content

Instantly share code, notes, and snippets.

@hsyntnc
Last active July 31, 2019 10:47
Show Gist options
  • Save hsyntnc/a488a5dece996dafdbb58000afad8e8f to your computer and use it in GitHub Desktop.
Save hsyntnc/a488a5dece996dafdbb58000afad8e8f to your computer and use it in GitHub Desktop.
total = 0;
function makeRequest(page, archived) {
var ysRequest = { CatalogName: "", Culture: "tr-TR", LanguageId: "", Token: ""}
var data = { archiveDbOrders: archived, pageNumber: page, ysRequest: ysRequest }
$.ajax({
type: "POST",
url: "https://www.yemeksepeti.com/Account/GetOrderHistory",
data: data,
success: function(resp){
resp.OrderHistoryItems.forEach(item => {
total = total + parseFloat(item.Total.split(' ')[0].replace(',', '.'))
console.log(item.Total + ' ' + item.OrderDateText);
});
if (resp.HasNextPage){
makeRequest(page+1, archived)
} else if (archived == false) {
makeRequest(1, true)
} else {
alert("Toplam Harcamanız: ₺" + total.toFixed(2));
}
}
});
}
makeRequest(1, false)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment