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

144
Vistas
How to get value from object property in React or Javascript

Why do I have to wrap await with () in order to get the output I need. I am hoping to get only the uid from the object

The data that is return from the function that I am importing is exactly how you see it

{uid : 'abcdefg', email:'youremail@gmail.com'}
import {ActiveUser} from './teamMembers.service';

export const retrieveList = async date => {
console.log('active user information here', (await ActiveUser()).uid); 
// outputs: Works as expected
// active user information here abcdefg

console.log('active user information here', await ActiveUser().uid); 
// outputs: 
//Undefined

console.log('active user information here', typeof (await ActiveUser()));
// outputs: 
// object
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The await operator is used to wait for a Promise (The Promise object represents the eventual completion (or failure) of an asynchronous operation and its resulting value) and it can only be used inside an async function.

You need to await you're async task (ActiveUser) once and after that you can just reference it's data (which is the resolved state of that async code happening there)

import {ActiveUser} from './teamMembers.service';

export const retrieveList = async date => {
   const data = await ActiveUser();
   const uid = data.uid;
   const name = data.name;
}

I suggest you read more The event loop and the concurrency model and it's secret behind the JavaScript's asynchronous programming.

More about async - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function

More about event loop - https://developer.mozilla.org/en-US/docs/Web/JavaScript/EventLoop

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