Skip to content

Instantly share code, notes, and snippets.

@aakashb95
Created December 28, 2021 18:06
Show Gist options
  • Save aakashb95/fd131fd83ac6f6740c5ecb0d28df7ab9 to your computer and use it in GitHub Desktop.
Save aakashb95/fd131fd83ac6f6740c5ecb0d28df7ab9 to your computer and use it in GitHub Desktop.
swiggy-all-orders
order_array=[]
order_id=''
page = 1
try {
while(true){
var xmlHttp = new XMLHttpRequest()
xmlHttp.open( "GET", "https://www.swiggy.com/dapi/order/all?order_id="+order_id, false )
xmlHttp.send( null )
resText=xmlHttp.responseText
var resJSON = JSON.parse(resText)
order_id=resJSON.data.orders[resJSON.data.orders.length-1].order_id
order_array=order_array.concat(resJSON.data.orders)
console.log("On page: "+page+" with last order id: "+order_id)
page++
}
}
catch(err) {
console.log(order_array)
}
@aakashb95
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment