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

477
Views
React Native: la exposición getCurrentPositionAsync no funciona

Así que estoy tratando de obtener las coordenadas actuales de los usuarios desde la ubicación de la exposición y probarlo usando el cliente de la exposición en mi teléfono Android. El siguiente código registra el estado como aprobado, pero la latitud y la longitud no se actualizan y en el iPhone aparece el siguiente error:

[Rechazo de promesa no manejado: Error: la solicitud falló con el código de estado 400] en node_modules/axios/lib/core/createError.js:15:17 en createError en node_modules/axios/lib/core/settle.js:16:9 en liquidación en node_modules/axios/lib/adapters/xhr.js:52:6 en handleLoad en node_modules/react-native/Libraries/Network/XMLHttpRequest.js:601:4 en setReadyState en node_modules/react-native/Libraries/Network/XMLHttpRequest .js:396:6 en __didCompleteResponse en node_modules/react-native/Libraries/vendor/emitter/_EventEmitter.js:135:10 en EventEmitter#emit

Código:

 const [latitude, setLatitude] = useState(); const [longitude, setLongitude] = useState(); const getLocationAsync = async () => { let { status } = await Location.requestForegroundPermissionsAsync(); if (status === 'granted') { console.log('Approved!'); return Location.getCurrentPositionAsync({ enableHighAccuracy: true }); } else { console.log('Rejected!'); throw new Error('Location permission not granted'); } } useEffect(() => { const location = getLocationAsync(); setLatitude(location.latitude); setLongitude(location.longitude); }, []);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

getLocationAsync es una función de promesa.

puedes cambiar este código

 useEffect(() => { (async () => { const { status } = await Location.requestForegroundPermissionsAsync(); if (status === 'granted') { console.log('Approved!'); const location = await Location.getCurrentPositionAsync({ enableHighAccuracy: true }); setLatitude(location.latitude); setLongitude(location.longitude); } else { console.log('Rejected!'); throw new Error('Location permission not granted'); } })(); }, []);
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!