Skip to content

Instantly share code, notes, and snippets.

@redraw
Created November 24, 2021 16:10
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 redraw/11b235dc1b0e984e8b15c22523d9f462 to your computer and use it in GitHub Desktop.
Save redraw/11b235dc1b0e984e8b15c22523d9f462 to your computer and use it in GitHub Desktop.
let more = true
let data = []
let offset = 0
while (more) {
console.log(`Fetch offset: ${offset}`)
var req = new XMLHttpRequest();
req.open("GET", `https://www.pedidosya.com.ar/mobile/v2/users/myOrders?state=CONFIRMED&max=10&offset=${offset}&countryId=3`, false);
req.send(null)
let response = JSON.parse(req.responseText)
data = data.concat(response.data)
more = response.count > 0
offset += 10
}
let blob = new Blob([JSON.stringify(data)], {type: "application/json"})
let elem = document.createElement("a")
elem.href = URL.createObjectURL(blob)
elem.download = "pedidosya.json"
elem.click()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment