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

73
Views
Los datos JSON no aparecen en el registro de la consola

Estoy tratando de obtener datos JSON para que aparezcan en el registro de la consola, pero por alguna razón no funciona. ¿Cómo almaceno los datos JSON en una variable e imprimo en la consola?

 const [lat, setLat] = useState([]); const [long, setLong] = useState([]); const [data, setData] = useState([]); useEffect(() => { const fetchData = async () => { navigator.geolocation.getCurrentPosition(function(position) { setLat(position.coords.latitude); setLong(position.coords.longitude); }); console.log("Latitude is:", lat) console.log("Longitude is:", long) await fetch(`${process.env.REACT_APP_API_URL}?location=${lat},${long}&timesteps=1d&units=imperial&apikey=${process.env.REACT_APP_API_KEY}&fields=treeIndex,weedIndex,grassIndex`) .then(res => res.json()) .then(res => { setData(res); console.log(res); }); } fetchData(); }, [lat, long]);
about 4 years ago · Juan Pablo Isaza
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!