Versionsvergleich
Aus ProgrammingWiki
Vergleich: 2018-06-11T16:01:11+00:00 → 2018-06-11T16:11:52+00:00
| + | <language>Javascript</language> |
Die API bietet mehrere Befehle an | |
| − | <code> |
| − | openweathermapAPI ("weather","Bern, CH", function(wetter){ console.log(wetter); }); |
| − | openweathermapAPI ("forecast","Bern, CH", function(vorhersage){ console.log(vorhersage); }); |
| − | </code> |
| − | |
<code id="code"> | |
var OWM_API_KEY = "1101927259087c982997f71cd981ab4a"; | |
function openweathermapAPI (befehl,q,callback){ | |
| − | $.getJSON("https://api.openweathermap.org/data/2.5/"+befehl+"?APPID="+OWM_API_KEY+"&q="+encodeURIComponent(q),function(results){ |
| + | $.getJSON("https://api.openweathermap.org/data/2.5/"+befehl+"?APPID="+OWM_API_KEY+"&units=metric&q="+encodeURIComponent(q),function(results){ |
callback(results); | |
}); | |
} | |
</code> | |
| + | |
| + | <run id="5b1e9cf2a7284"> |
| + | openweathermapAPI ("weather","Bern, CH", function(wetter){ console.log(wetter); }); |
| + | </run> |
| + | |
| + | <run id="5b1e9d1787aae"> |
| + | openweathermapAPI ("forecast","Bern, CH", function(vorhersage){ console.log(vorhersage); }); |
| + | </run> |