📌  相关文章
📜  polkadot UnhandledPromiseRejectionWarning: Error: Api need to be initialized before using, listen on 'ready' - Javascript代码示例

📅  最后修改于: 2022-03-11 15:02:27.355000             🧑  作者: Mango

代码示例1
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}`);
});