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

159
Vistas
Promise { <pending> } in Web3

I need something help.. I'm trying to make an async request but the response is a Promise { <pending> }

This is my code

const getBalance = async (adress) => {
  try {
    let wei = await web3.eth.getBalance(address);
  } catch (err) {
    console.error(err);
  }
};

let balanceWallet = getBalance(address);
console.log(balanceWallet);

So when I run my code to debug it returns Promise { <pending> } I don't know what's wrong in my code

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

0

getBalance is an async function :) JS does not allow us to use async/await on the program top level but we can use then/catch to get promise result)

You just have to use (but before u have to change getBalance function and return promise there)

const getBalance = (adress) => web3.eth.getBalance(address);

getBalance(address)
.then(balanceWallet => {
  console.log(balanceWallet)
  // some logic with result
})
.catch(error => /** handle an error **/ )

I hope it helps! Enjoy programming!

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