how to get block information using node js
The function client.getBlockchainInformation and the other methods exposed by the bitcoin-core npm module use bitcoin-core's REST interface. In order to use it, however, it must be enabled when you start bitcoind with the -rest flag.


  The REST API can be enabled with the -rest option.
  
  The interface runs on the same port as the JSON-RPC interface, by
  default port 8332 for mainnet, port 18332 for testnet, and port 18443
  for regtest.


e.g.:

$ bitcoind -rest

or in bitcoin.conf

rest=1