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

211
Vistas
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
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