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

154
Views
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
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!