Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

141
Vistas
await Asyncstorage returns a promise

I am using a helper function to get the token from Asyncstorage and add it to the axios header but instead it gives a promise. My function is like this:

const getToken = async () => {
  const token = await AsyncStorage.getItem("token")
    return token
};
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Here's some information about how to handle promises:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise

I believe the parameter of the callback that you pass to .then will receive the value that your asynchronous function "returns."

about 4 years ago · Juan Pablo Isaza Denunciar

0

you are awaiting the token, it's supposed to return a promise. the correct way is:

async function getToken() {
  return await AsyncStorage.getItem("token");
}

OR

const getToken = async () => {
  return await AsyncStorage.getItem("token")    
};
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda