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

158
Views
Uncaught TypeError: Cannot read property 'lat' of undefined React.JS

I have this code that takes the user's location, but when the user does not accept the permission, it sends the error of the question, how could I assign a value to it if the user left it empty?

const request = {
                method: 'POST',
                headers: {
                    "Content-Type": "application/json",
                    "Accept": "application/json"
                },
                body: JSON.stringify({
                    type: "sso",
                    ...state,
                    card: cifrado,
                    latitud: location.coordinates.lat,
                    longitud: location.coordinates.lng,
                    aceptacion: location.aceptacion
                }),
                latitud: location.coordinates.lat,
                longitud: location.coordinates.lng,
                aceptacion: location.aceptacion
            }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

latitud: location?.coordinates.lat || '',
longitud: location?.coordinates.lng || '',

or

 body: JSON.stringify({
                type: "sso",
                ...state,
                card: cifrado,
                ...(location.cooridantes ? {
                  latitud: location.coordinates.lat,
                  longitud: location.coordinates.lng    
                 } : {}),
                aceptacion: location.aceptacion
            })
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!