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

115
Vistas
How to export a user variable

I have some google user information that I want to export as it is async I have an async function that works well the problem is that the second module is not getting it despite I created an async function waiting for it. Please help of course I am new. Moldule 1:

  export async function setU (u) {
     
    let user= await u; 
    console.log(user.uid)        
    return user   
}

This gets the info without problem, the problem is when importing.

   import {login,cerrar,setU} from '/js/log_principal.js'

The next function in module 2 does not work. Module:2

       login() 

  //getInfo(datos)
  
  b(setU)   

async function b(usuario){    
   
    let user= await usuario;        
   console.log(user.uid) // this gives undefined!!! :(


    
}


    
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I think you are not understanding correctly what you import when importing a function.

What you do here is passing a function (which is not executed) thru a different function like:

function demonstration(await function user() {}) {
  // code...
}

instead you first want to execute the function and then pass it thru the function

The solution is quite simple

File1.js

export async function setU (u) {
  let user = await u; 
  console.log(user.uid);     
  return user;
}

File2.js

import {login,cerrar,setU} from '/js/log_principal.js'

login() 

b(setU)   

async function b(usuario){
  let user= await usuario;        
  console.log(user.uid);
}
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