- open web browser and hit https://www.singtel.com/bin/services/singtel/getStockData.:groupId=Apple%20iPhone%208%20Plus_Apple%20iPhone%20X.json
- open developer console and copy step 1 response json and initiate variable:
var data = \\ paste the response
- 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)
}
})
}
- type's value can be 0, 1, 2, 3.
- 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