0

My webpage is not rendering the a table with sample code below. I can see on the Browser Console the promised block objects but this message shows:

Source map error: request failed with status 403 Resource URL: https://cdn.ethers.io/scripts/ethers-v4.min.js Source Map URL: ethers.min.js.map[Learn More]

I believe this could be the issue of not getting the page table udpdated with the information.

-blockgeeks code:

<script src="./web3.min.js"></script>
<script src="./web3.min.js"></script>

<script>
    window.onload = function() {
        updateBlocks();
    };
    async function updateBlocks() {
        let web3 = new Web3(new Web3.givenProvider);
        let latest = await web3.eth.getBlockNumber();


        for (var i=0; i < 10; i++) {
            let block = await web3.eth.getBlock(latest-i);
            printBlock(block);
        }
    }
    function printBlock(block) {
        var table = document.getElementById('blocks');
        var row = table.insertRow(-1);
        var cell1 = row.insertCell(0);
        var cell2 = row.insertCell(1);
        var cell3 = row.insertCell(2);
        cell1.innerHTML = block.number;
        cell2.innerHTML = block.hash;
        cell3.innerHTML = block.timestamp;
    }
</script>
0

Issue was tied to problem described here:

https://stackoverflow.com/questions/57064039/how-to-fix-page-not-updating-cell-info-with-innerhtml-on-async-function/57066299#57066299

Issue solved with ganache-cli and change givenProvider with Web3.providers.HttpProvider instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.