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

123
Views
La llamada a la función devuelve Promise {_U: 0, _V: 0, _W: null, _X: null} en lugar de verdadero o falso

Estoy tratando de llamar a mi función NetInfo de esta manera en un archivo separado:

 import NetInfo from '@react-native-community/netinfo'; export default class checkNetwork { static async isNetworkAvailable() { const response = await NetInfo.fetch(); return response.isConnected; } }

Archivo redux

 const connectionStatus = async () => { await checkNetwork.isNetworkAvailable(); }; const isConnected = connectionStatus(); console.log('status of network >>', isConnected);

En lugar de true o false , devolvió una promesa Promise {_U: 0, _V: 0, _W: null, _X: null} .

¿Cómo soluciono esto para devolver un valor booleano?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

La función asíncrona siempre devuelve una promesa y, para resolverla, debe esperarla, así que simplemente agregue await delante de la función connectionStatus .

 const isConnected = await connectionStatus();

Si está utilizando react saga (generadores) para lograrlo, puede usar yield en lugar de await .

 const isConnected = yield connectionStatus();
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!