Created
March 20, 2014 15:49
-
-
Save willyaranda/9666868 to your computer and use it in GitHub Desktop.
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
'use strict'; | |
var request = require('request'), | |
ABOUT_URL = 'https://push-nv.srv.openwebdevice.com/willy'; | |
var debug = function(msg) { | |
var d = Date.now(); | |
console.error(Date(d).toLocaleString(), d, msg); | |
}; | |
var requestAbout = function() { | |
request(ABOUT_URL, function(error, response, body) { | |
if (error) { | |
debug(error); | |
return; | |
} | |
if (response.statusCode !== 200) { | |
debug(response.statusCode); | |
return; | |
} | |
if (body.indexOf('Hello') === -1) { | |
debug('Bad body' + body); | |
return; | |
} | |
debug('Fine'); | |
}); | |
}; | |
setInterval(requestAbout, 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment