Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

161
Vistas
Lat and Long is showing not defined when using template literals

Using Accuweather API to create a weather app. I believe I have messed up somewhere with syntax but I can't figure out where I went wrong. Any advice?

Line 26:100: 'lat' is not defined no-undef

Line 26:109: 'long' is not defined no-undef

import { useEffect, useState } from "react";
    
    function Location() {
      let [data, setData] = useState([]);
      const key = process.env.REACT_APP_API_KEY;
      
    
      useEffect(() => {
        if (!data) return;
    
       if (navigator.geolocation) {
         navigator.geolocation.getCurrentPosition(successFunction, console.log());
       } else {
         alert(
           "It seems like Geolocation, which is required for this page, is not enabled in your browser. Please use a browser that supports it."
         );
       }
        function successFunction(latlong) {
          const lat = latlong.coords.latitude;
          const long = latlong.coords.longitude;
          console.log("latlong = " + lat + ", " + long);
        
        }
        
        fetch(
          `http://dataservice.accuweather.com/locations/v1/cities/geoposition/search?apikey=${key}&q=${lat}%2C${long}`
        )
          .then((response) => response.json())
          .then((data) => setData(data))
          .catch((err) => console.log(`Error Meassage ${err}`));
      }, []);
      console.log("location key = ", data.Key);
    }
    
    export default Location;
about 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda