Failed to invoke successfully :: TypeError: fabric_client.newEventHub is not a function


#1

Received this error when running ‘node invoke.js’


#2

Open invoke.js in your text editor.

comment lines 105 and 106
//let event_hub = fabric_client.newEventHub();
//event_hub.setPeerAddr(‘grpc://localhost:7053’);

add this line instead.

	let event_hub = channel.newChannelEventHub('localhost:7051');

Then comment line 131
//console.log('The transaction has been committed on peer ’ + event_hub._ep._endpoint.addr);

and add the below line instead.

console.log('The transaction has been committed on peer ' + event_hub.getPeerAddr());

Now save the file and execute. It should work now.