Last active
February 24, 2016 17:35
-
-
Save MxAshUp/9c9bd64dbe3f42200192 to your computer and use it in GitHub Desktop.
Checks Pi Hut Pi Zero Inventory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Requires node-notifier for desktop notification | |
path = "products/raspberry-pi-zero.js" | |
request = require('request-json'); | |
var client = request.createClient("http://thepihut.com/"); | |
function check_availability() { | |
client.get(path, function(err, res, body) { | |
if(body && body.variants[4].available == true) { //I have hard-coded which product variation is associated with the Pi Zero. This should be changed if PiHut changes their Pi Zero variations. | |
var notifier = require('node-notifier'); | |
notifier.notify({ | |
title: 'PI ZERO IN STOCK', | |
message: 'The Pi ZERO IN STOCK!!!!', | |
sound: true, // Only Notification Center or Windows Toasters | |
}); | |
console.log("AVAIALBE!!!!!!!!!!!!!!"); | |
} else { | |
setTimeout(check_availability,1000); | |
} | |
}); | |
} | |
check_availability(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment