Skip to content

Instantly share code, notes, and snippets.

@silentrob
Created December 11, 2014 23:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save silentrob/ad795eb955c9f6478814 to your computer and use it in GitHub Desktop.
Save silentrob/ad795eb955c9f6478814 to your computer and use it in GitHub Desktop.
Weather Plugin
var request = require("request");
debug = require("debug")("Weather Plugin");
exports.weather = function(city, cb) {
request.get("http://api.openweathermap.org/data/2.5/find?q="+city+"&type=like&mode=json", function(err, res, body) {
// debug("Weather Results", body);
var results = JSON.parse(body);
if (results.list.length != 0) {
cb(null, "It is " + results.list[0]['weather'][0]['description']);
} else {
cb(null, "I'm not near a window.");
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment