Me gustaría obtener el parámetro "weatherdata" de la función GetDatas() en mi h4. Llevo un tiempo intentándolo, pero no sé cómo hacerlo.
function GetDatas(e){ e.preventDefault(); console.log(cityname) fetch(cityURI) .then(city => city.json()) .then(citydata => { fetch(`http://api.openweathermap.org/data/2.5/forecast?lat=${citydata[0].lat}&lon=${citydata[0].lon}&appid=${key}`) .then(weatherdata => weatherdata.json()) .then(weatherdata => { return weatherdata }) }); } return ( <div className="cityinput"> <form onSubmit={() => {GetDatas();}}> <label >City name</label> <input type="text" onChange={(e) => SetCityname(e.target.value)} /> </form> <div> <h4>Name: {weatherdata.name}</h4> </div> </div> );Intente almacenar su respuesta de weatherData en una variable de estado. Y use esa variable de estado para representar condicionalmente su weatherData.name en su JSX. es decir, {weatherData && weatherData.name && <h4>{weatherData.name}</h4>}