Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

155
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda