Skip to content

Instantly share code, notes, and snippets.

@AndreasFurster
Created February 23, 2020 00:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndreasFurster/db7d2d0a4e8de6d1d1bd4cee93bfdd18 to your computer and use it in GitHub Desktop.
Save AndreasFurster/db7d2d0a4e8de6d1d1bd4cee93bfdd18 to your computer and use it in GitHub Desktop.
Download Karwei/Gamma Receipts
let result = [];
var receiptsResp = await fetch("https://mijn.karwei.nl/api/receipts", {
"headers": {
"accept": "application/json",
"accept-language": "en-US,en;q=0.9,nl;q=0.8",
"cache-control": "no-cache",
"content-type": "application/json",
"pragma": "no-cache",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-origin"
},
"referrer": "https://mijn.karwei.nl/",
"referrerPolicy": "same-origin",
"body": null,
"method": "GET",
"mode": "cors",
"credentials": "include"
});
var receipts = await receiptsResp.json();
for (let i = 0; i < receipts.length; i++) {
// for (let i = 0; i < 1; i++) {
const receipt = receipts[i];
const id = receipt.receiptId
var receiptInfoResp = await fetch(`https://mijn.karwei.nl/api/receipts/${id}`, {
"headers": {
"accept": "application/json",
"accept-language": "nl",
"cache-control": "no-cache",
"content-type": "application/json",
"pragma": "no-cache",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-origin"
},
"referrer": `https://mijn.karwei.nl/kassabonnen/${id}`,
"referrerPolicy": "same-origin",
"body": null,
"method": "GET",
"mode": "cors",
"credentials": "include"
});
var receiptInfo = await receiptInfoResp.json();
var additionalInfo = JSON.parse(JSON.stringify(receiptInfo))
delete additionalInfo.coupons
delete additionalInfo.lineItems
for (let j = 0; j < receiptInfo.lineItems.length; j++) {
let lineItem = receiptInfo.lineItems[j];
result.push({...lineItem, ...additionalInfo});
}
}
console.log(JSON.stringify(result));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment