Created
February 23, 2020 00:29
-
-
Save AndreasFurster/db7d2d0a4e8de6d1d1bd4cee93bfdd18 to your computer and use it in GitHub Desktop.
Download Karwei/Gamma Receipts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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