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

202
Views
How to get resolved value of promise then export using module.exports?

I have this Promise snippet,

    let myPromise = new Promise(async function(resolve, reject){

    const defaultConfig = {
            s3: {
                region: process.env.ENV_S3_REGION,
                accessKeyId: await juice.string('S3.ACCESS_KEY_ID', juice.MANDATORY),
                secretAccessKey: process.env.ENV_S3_SECRET_ACCESS_KEY
            },
            uploadConfig: { 
                bucket: process.env.ENV_UPLOAD_BUCKET
            }
}
   resolve(defaultConfig);
}

And I'd like to module.export the defaultConfig object. So I did this at the end of the code,

myPromise.then(res => module.exports = res)

But when calling in on other file, it can't get the value, it gives me undefined. But if I console.log the res like, this I can output the value.

myPromise.then(res => console.log(res))
about 4 years ago · Juan Pablo Isaza
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!