function setupProductEventListner() {
let productEvent;
EcommerceStore.deployed().then(i => {
productEvent = i.NewProduct({fromBlock: 0, toBlock: 'latest'});
console.log(productEvent);
productEvent.watch((error,result)=>{
if (error) {
console.log(error);
return;
}
saveProduct(result.args);
});
})
}
控制台信息
node app/server.js Ebay Ethereum server listening on port 3000! EventEmitter { _events: [Object: null prototype] {}, _eventsCount: 0, _maxListeners: undefined,
} (node:34260) UnhandledPromiseRejectionWarning: TypeError: productEvent.watch is not a function at G:\myProject\ebay_dapp\app\server.js:61:22 at processTicksAndRejections (internal/process/task_queues.js:93:5)