Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

126
Views
obtener un parámetro en reaccionar

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> );
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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>}

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!