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

105
Views
Acceder a datos de objetos dentro de una promesa

Así que tengo un método getBlockByHeight que es el siguiente.

 getBlockByHeight(height) { let self = this; return new Promise((resolve, reject) => { try{ let block = self.chain.filter(p => p.height === height)[0]; if(block){ resolve(block); } else { resolve(null); } } catch (err) { reject(new Error(err)); } }); }

Luego quiero validar mis bloques en otro método y estoy tratando de hacer lo siguiente.

 let previousBlock = self.getBlockByHeight(block.height -1);

Esa línea devuelve una promesa con mi objeto de bloque correctamente. Si consola.log anteriorBlock se imprime de la siguiente manera.

 Promise { Block { hash: '5535a9bf09a3667a533df8f8a90a6ae8e8dfe1ca9f3d5305df5a1d593d2afcf6', height: 1, body: 'longHexString', time: '1633881202', previousBlockHash: '1f018de4cb50fe2fc57b43c1a4972fde53d7e4ab9ca5809784d49e5a57497312' } }

Mi pregunta es cómo accedo al hash en este objeto de bloque anterior. si lo intento

 let preBlockHash = previousBlock.hash

Me quedo indefinido. No estoy muy seguro de por qué sucede esto, por lo que agradecería cualquier ayuda, gracias.

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!