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

116
Views
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 answers
Answer question

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 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!