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

97
Vistas
Returning a variable from another async function in Javascript returns undefined

I'm trying to run a function that sets up a bunch of things for my code. The first thing is getting a JSON object from an api to use later. When I run the code and console log the abi in the getAbi function, it logs out the JSON.

When I do the same thing from another function it returns undefined.

How can I fix this? I assume it's because the code is running before its returned, but I can't figure out how to get it in order.

async function getAbi (contract) {
    
    if (config['abi'] != ""){
        abi = config['abi']
        return abi
    }else {
        request('https://api.etherscan.com/api?module=contract&action=getabi&address='+ contract + '&apikey=' + bscScanToken, async (err, response, body) => {
            if (err) {
                console.log(err)
            } else{ 
                body = JSON.parse(body)
                abi = body.result
                return abi
            }
        })
    }
}

async function setupMint() {
    abi = await getAbi(contract)
    console.log(abi)
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