The sample code in README throws an error Cannot read property 'then' of undefined
var {Apis} = require("peerplaysjs-lib");
Apis.instance("wss://bitshares.openledger.info/ws").init_promise.then((res) => {
console.log("connected to:", res[0].network);
Apis.instance().db_api().exec( "set_subscribe_callback", [ updateListener, true ] )
});
I believe the error is because init_promise is a property of the ApisInstance object only after the connect phase. Apis.instance() only connects to the connection string if a second parameter is provided as true according to the code. Hence modifying the code as below resolves the issue:
var {Apis} = require("peerplaysjs-lib");
Apis.instance("wss://bitshares.openledger.info/ws", true).init_promise.then((res) => {
console.log("connected to:", res[0].network);
Apis.instance().db_api().exec( "set_subscribe_callback", [ updateListener, true ] )
});
The sample code in README throws an error
Cannot read property 'then' of undefinedI believe the error is because init_promise is a property of the ApisInstance object only after the connect phase. Apis.instance() only connects to the connection string if a second parameter is provided as
trueaccording to the code. Hence modifying the code as below resolves the issue: