Code viewer for World: Hello Weather ai api
//AI Weather by Meteosource api link: https://rapidapi.com/MeteosourceWeather/api/ai-weather-by-meteosource

async function getWeather() {
        const url = `https://ai-weather-by-meteosource.p.rapidapi.com/hourly?lat=53.33306&lon=-6.24889&timezone=auto&language=en&units=metric`;
        const options = {
	    method: 'GET',
	    headers: {
		    'X-RapidAPI-Key': '6f9a7275a0msh307bfbf770ae5aap199127jsn14c0d405bc2e',
		    'X-RapidAPI-Host': 'ai-weather-by-meteosource.p.rapidapi.com'
	    }
    };

    try {
	    const response = await fetch(url, options);
	    const result = await response.json();
        //console.log(result);
        displayWeather(result);
    } catch (error) {
	    console.error(error);
    }
}

function displayWeather(data) {
    document.write(`<h1>An example api call from the weather ai api from rapidapi.com<h1>
    <h3>api created by MeteosourceWeather</h3>
    This is showing the hourly weather of Dublin, predicted by the AI:<br>`);
    
    
    document.write("<br> - " + "timezone" + ": " + data["timezone"]);
    document.write("<br> - " + "units" + ": " + data["units"]);
    var hourly = data["hourly"]["data"];
    
    for (var i = 0; i < hourly.length; i++) {
        console.log(i);
        var obj = hourly[i];
        document.write("<br> - " + "date" + ": " + obj["date"]);
        document.write("<br> - " + "temperature" + ": " + obj["temperature"] + " degrees celsius");
        document.write("<br> - " + "feels like" + ": " + obj["feels_like"] + " degrees celsius");
        document.write("<br> - " + "weather summary" + ": " + obj["weather"]);
        document.write("<br> - " + "humidity" + ": " + obj["humidity"] + "%");
        document.write("<br> - " + "Wind Speed" + ": " + obj["wind"]["speed"] + "km/h");
        document.write("<br> - " + "precipitation probability" + ": " + obj["probability"]["precipitation"] + "%");
        document.write("<br>");
    }
}

getWeather();