Skip to content

Instantly share code, notes, and snippets.

@anuith
Created December 20, 2012 05:34
Show Gist options
  • Save anuith/4343152 to your computer and use it in GitHub Desktop.
Save anuith/4343152 to your computer and use it in GitHub Desktop.
the getWeatherFromLocation function
function getWeatherFromLocation(lat, lon) {
return new WinJS.Promise(function (complete, error, process) {
WinJS.xhr({ url: "http://api.wunderground.com/api/" + apiKey + "/conditions/q/" + lat + "," + lon + ".json" })
.then(function (xhr) {
var result = JSON.parse(xhr.responseText).current_observation;
var condition = {
icon: result.icon_url,
temp: result.temp_c,
location: result.display_location.full
};
complete(condition);
}, function (err) {
error(err);
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment