4 ms·
Braking javascript Promises are such a mess
Just one of many examples of recently silently braking code:
balance=web3.eth.getBalance(sender);
console.log(balance.toFixed(3))
Used to work, now it prints NaN.
What's going on? Well getBalance now returns a Promise. IMHO thats the worst category of bug introduction the industry has seen after the goto keyword.
It can't even be fixed by simply adding the await keyword, it has to be wrapped in an async function.
balance=await web3.eth.getBalance(sender);
Top level await is not allowed in node.js.
- hitripekac 9y agoIt looks like the API of the library you're using has changed. Before you update the library you should really check the release notes for braking changes. For npm, you should probably even look more closly at the releases, and update carefully, as the quality of libraries ranges from great to "should not be used in production ever".