Skip to content

Instantly share code, notes, and snippets.

@stevedep
Created July 29, 2023 06:58
Show Gist options
  • Save stevedep/2f431d27fcfbe40c7816fac261df3253 to your computer and use it in GitHub Desktop.
Save stevedep/2f431d27fcfbe40c7816fac261df3253 to your computer and use it in GitHub Desktop.
async function getTransactions(i) {
let response = await // fetch here
let data = await response.json();
return data;
}
function process(r, i, a) {
console.log(i)
result.push(r[0].data.recipeSearch.result)
if (i == a){ //* 1 + 7))) {
console.log("download")
//download("ah.json", result);
}
}
function download(filename, text) {
var pom = document.createElement('a');
pom.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(JSON.stringify(text)));
pom.setAttribute('download', filename);
if (document.createEvent) {
var event = document.createEvent('MouseEvents');
event.initEvent('click', true, true);
pom.dispatchEvent(event);
}
else {
pom.click();
}
}
result = []
a = 2//217
for (let index = 0; index <= a; index++) {
await getTransactions(index).then(data => process(data, index, a));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment