-
Notifications
You must be signed in to change notification settings - Fork 7
Error in README #53
Copy link
Copy link
Open
Description
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 ] )
});
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels