Whenever I try to get the block using the eosjs in NodeJS like in the example I get the error 'Invalid Block number or ID, must be greater than 0 and less than 64 characters'
Altho when I use other fetch methods such as the fetch from nodeos, it works just fine: https://developers.eos.io/eosio-nodeos/reference#get-block
I got the info on how to do this fetch from the eos documentation: https://eosio.github.io/eosjs/latest/reading-blockchain-examples/#get-block
const { JsonRpc } = require('eosjs');
const fetch = require('node-fetch');
const rpc = new JsonRpc('https://api.eosnewyork.io/', { fetch });
async function main() {
try {
let info = await rpc.get_info();
console.log(await rpc.get_block(info.last_irreversible_block_num));
} catch (error) {
console.error(JSON.stringify(error));
}
}
main();