I am trying to make a make a simple blockchain project to exercise nodejs. I created a blockchain object that is formed of block class and i want to iterate throught this object using pug.
app.get('/', function(request, response, next){
response.render('opetations', {"blockChain":blockChain});
});
each block in blockChain
tr
th(scope='row') block
td block.index
when i coded it like this it iterates just once and it doesnt print the index value. I think its because of my blockChain object. When i convert it into json it looks like the image attached. I think its because of my objects structure. Can you help me with this issue.
https://i.stack.imgur.com/zfvgp.png
I want to iterate through my blockchain object and print the block values on a table
CodePudding user response:
It's blockchain.blockchain
then.
So try passing it like this:
response.render('opetations', {"blockChain":blockChain.blockchain});
You also need to output values, check the docs.
It should look like this:
each block in blockchain
table
tr
th(scope='row')= block.index
td= block.data.name