Skip to content

Instantly share code, notes, and snippets.

@shuson
Created November 6, 2017 01:56
Show Gist options
  • Save shuson/a9f53cd6247a5e06fa722bed20a115f4 to your computer and use it in GitHub Desktop.
Save shuson/a9f53cd6247a5e06fa722bed20a115f4 to your computer and use it in GitHub Desktop.
  1. open web browser and hit https://www.singtel.com/bin/services/singtel/getStockData.:groupId=Apple%20iPhone%208%20Plus_Apple%20iPhone%20X.json
  2. open developer console and copy step 1 response json and initiate variable:
  var data = \\ paste the response
  1. copy and paste this function to console
function extract(data, type){
  console.log("---------------iPhone X Stock--------------------")
  var iphoneType = data[1].items[type]
  console.log(iphoneType.description.color)
  console.log(iphoneType.description.size)
  iphoneType.data.forEach(function(item){
    if(item.stock_status != "Not Available"){
      console.log("\tshop name " + item.shop.name)
      console.log("\t\tstock status " + item.stock_status)
    }
  })
}
  1. type's value can be 0, 1, 2, 3.
  2. call extract(data, 3), it would show something like:
---------------iPhone X Stock--------------------
  VM615:4 Space Gray
  VM615:5 64GB
  VM615:8 	shop name Singtel Pop Up Shop
  VM615:9 		stock status Selling Fast
  VM615:8 	shop name Singtelshop.com
  VM615:9 		stock status Selling Fast
  VM615:8 	shop name Singtel Exclusive Retailer West Mall
  VM615:9 		stock status Available
  VM615:8 	shop name Singtel Exclusive Retailer Bedok Mall
  VM615:9 		stock status Selling Fast
  VM615:8 	shop name Singtel Exclusive Retailer NEX
  VM615:9 		stock status Selling Fast
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment