import React from "react"; import Navbar4 from "../components/navbar4"; import Footer15 from "../components/footer15"; import "./home.css"; import "./data.css"; const Weatherforecast = (props) => { function getData() { const city = document.getElementById("city").value; const region = document.getElementById("region").value; const country = document.getElementById("country").value; const latitude = document.getElementById("latitude").value; const longitude = document.getElementById("longitude").value; const temperature = document.getElementById("temperature").checked; const isDay = document.getElementById("isDay").checked; const condition = document.getElementById("condition").checked; const pressure = document.getElementById("pressure").checked; const precipitation = document.getElementById("precipitation").checked; const humidity = document.getElementById("humidity").checked; const cloud = document.getElementById("cloud").checked; const feelslikeTemp = document.getElementById("feelslikeTemp").checked; const visibility = document.getElementById("visibility").checked; const uv = document.getElementById("uv").checked; const gust = document.getElementById("gust").checked; const airquality = boolToWord( document.getElementById("airquality").checked ); const unitTemperature = document.getElementById("unitTemperature").value; const unitWindSpeed = document.getElementById("unitWindSpeed").value; const unitPressure = document.getElementById("unitPressure").value; const unitPrecipitation = document.getElementById("unitPrecipitation").value; const output = document.getElementById("output").value; const format = document.getElementById("format").value; const apiKey = "1244099aeaee4b179e6111803241304"; const apiUrl = `https://api.weatherapi.com/v1/current.${format}?key=${apiKey}&q=${city}&aqi=${airquality}`; fetch(apiUrl) .then((response) => { if (!response.ok) { throw new Error("Network response was not ok"); } return response.json(); }) .then((data) => { // Wetterdaten anzeigen document.getElementById("weatherData").innerText = JSON.stringify( data, null, 2 ); document.getElementById("apiUrloutput").value = apiUrl; }) .catch((error) => { console.error("There was a problem with the fetch operation:", error); }); } function searchAPI() { const cityInput = document.getElementById("city").value; const apiKey = "1244099aeaee4b179e6111803241304"; const apiUrl = `https://api.weatherapi.com/v1/search.json?key=${apiKey}&q=${cityInput}`; fetch(apiUrl) .then((response) => { if (!response.ok) { throw new Error("Network response was not ok"); } return response.json(); }) .then((data) => { // Wetterdaten anzeigen document.getElementById("weatherData").innerText = JSON.stringify( data, null, 2 ); }) .catch((error) => { console.error("There was a problem with the fetch operation:", error); }); } function boolToWord(bool) { return bool ? "yes" : "no"; } return (


















Output:



        

); }; export default Weatherforecast;