Function Parameters with Node.js Promise

I'm using blockexplorer API for blockchain, and I want to get block data based on specific hash (This hash should be taken from another function).

I'm new with using Promise, So can anyone help me to get the block data?

This is my code:

const be = require('blockexplorer');

be.block(be.blockIndex(0))
.then((result) => {
console.log(result)
})
.catch((err) => {
throw err
})

Also, I’ve tried another way with using nested Promise but it didn’t work.

#javascript #node-js #blockchain

3.45 GEEK