Answers for "polkadot UnhandledPromiseRejectionWarning: Error: Api needs to be initialized before using, listen on 'ready'"

0

polkadot UnhandledPromiseRejectionWarning: Error: Api needs to be initialized before using, listen on 'ready'

import { ApiRx } from '@polkadot/api';

// initialise via static create
const api = await ApiRx.create().toPromise();

// make a call to retrieve the current network head
api.rpc.chain.subscribeNewHeads().subscribe((header) => {
  console.log(`Chain is at #${header.number}`);
});
Posted by: Guest on September-26-2020

Code answers related to "polkadot UnhandledPromiseRejectionWarning: Error: Api needs to be initialized before using, listen on 'ready'"

Code answers related to "Javascript"

Browse Popular Code Answers by Language