Created
June 23, 2014 13:34
-
-
Save rsbohn/d8082333e3aaad86ed4b to your computer and use it in GitHub Desktop.
Get current observations from Weather Underground.
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
var http = require("http"); | |
var api_key = "YOUR_KEY_HERE"; | |
var report = function(location) { | |
http.get("http://api.wunderground.com" | |
+ "/api/" + api_key | |
+ "/conditions/q/" + location + ".json", | |
function (res) { | |
var all = ""; | |
res.on("data", function (part) { | |
all = all + part; | |
}); | |
res.on("end", function (fin) { | |
var response = JSON.parse(all); | |
if (response.current_observation !== undefined) { | |
var cobs = response.current_observation; | |
console.log(JSON.stringify(cobs)); | |
} | |
}) | |
}) | |
.on("error", function (err) { | |
console.error(err); | |
}); | |
}; | |
report("pws:KAZPHOEN77"); | |
report("pws:KUTOREM11"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment