Hi everyone, im doing my first app on this plataform Felgo, so im starting to learn.
Im trying to get some weather data from external API. In this case im using Dark Sky API.
Im gonna public my private API for help ^^ after that i will reset secret key 😀
Im trying to get data from the page and then create some labels on the app like
[Image of Sun]
Sunny, 40ºF/C
My private key:
https://api.darksky.net/forecast/68719c22555faabee724bc9533b1080a/37.8267,-122.4233
I was reading those documents: https://felgo.com/doc/vplay-xmlhttprequest/ and http://doc.qt.io/qt-5/qtqml-javascript-qmlglobalobject.html and https://darksky.net/dev/docs/forecast .
By the way i did this:
function weatherget() {
var httpRequest = new XMLHttpRequest();
httpRequest.open("GET", "https://api.darksky.net/forecast/68719c22555faabee724bc9533b1080a/37.8267,-122.4233", true);
httpRequest.onreadystatechange = function() {
if (httpRequest.readyState == httpRequest.DONE) {
var serverResponse = httpRequest.responseText;
console.debug("weatherget() httpRequest result:", serverResponse);
if(!serverResponse) {
nativeUtils.displayMessageBox("Ooops! Parece que no tienes conexión");
return;
}
var result = JSON.parse(serverResponse);
}
}
}
But on my test app i dont get any response, on debugger console or even message or something.
How i get this data example:
{
"latitude": 47.20296790272209,
"longitude": -123.41670367098749,
"timezone": "America/Los_Angeles",
"currently": {
"time": 1453402675,
"summary": "Rain",
"icon": "rain",
"nearestStormDistance": 0,
"precipIntensity": 0.1685,
"precipIntensityError": 0.0067,
"precipProbability": 1,
"precipType": "rain",
"temperature": 48.71,
"apparentTemperature": 46.93,
"dewPoint": 47.7,
"humidity": 0.96,
"windSpeed": 4.64,
"windBearing": 186,
"visibility": 4.3,
"cloudCover": 0.73,
"pressure": 1009.7,
"ozone": 328.35
},
"minutely": {
"summary": "Rain for the hour.",
"icon": "rain",
"data": [
{
"time": 1453402620,
"precipIntensity": 0.1715,
"precipIntensityError": 0.0066,
"precipProbability": 1,
"precipType": "rain"
},
...
]
},
"hourly": {
"summary": "Rain throughout the day.",
"icon": "rain",
"data": [
There’s a ton of data, but i only want some fields like actual ºC/ºF, Sunny/Clouds and basic stuff, how i get this data and public it directly to main screen of the app?
Is there any detailed guide for using XMLHttpRequest? For do what im trying i have to use XMLHttpRequest or there’s another way to do this?.
Thanks.