Created
December 20, 2012 05:34
-
-
Save anuith/4343152 to your computer and use it in GitHub Desktop.
the getWeatherFromLocation function
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
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