View Single Post
Markkyboy's Avatar
Posts: 433 | Thanked: 727 times | Joined on Oct 2012 @ Costa Blanca, Espaņa
#102
Hi all,

I've made myself a basic weather application, it uses the OpenWeatherMap.org API for data.

I would like to know how to enter my Weather API URL to my `weather.js` file using Dialog, but I'm unsure how to do it. I have played around with the example from Jolla, but I don't know quite what I'm doing......help!

The weather.js file uses XmlHttpRequest to fetch the data.

Code:
function requestWeatherData(cntr) {
    var xhr = new XMLHttpRequest;
    xhr.open("GET", `MY API KEY AND ID HERE`);
    xhr.onreadystatechange = function () {
        if (xhr.readyState === XMLHttpRequest.DONE) {
            cntr.weatherData = JSON.parse(xhr.responseText)
        }
    }
    xhr.send();
}
thanks,
__________________
..oO(Don't just sit there standing around, pick up a shovel and sweep up!)Oo..
 

The Following User Says Thank You to Markkyboy For This Useful Post: