Skip to content

Instantly share code, notes, and snippets.

@rsbohn
Created June 23, 2014 13:34
Show Gist options
  • Save rsbohn/d8082333e3aaad86ed4b to your computer and use it in GitHub Desktop.
Save rsbohn/d8082333e3aaad86ed4b to your computer and use it in GitHub Desktop.
Get current observations from Weather Underground.
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