I am busy writing a service to return data to a component in my angular app (ng4). The data is retrieved from a smart contract.
I seem to be getting the following error:
HomeComponent_Host.html:1 ERROR TypeError: this.smartContractService.getDrawId(...).subscribe is not a function
My component code:
this.smartContractService.getDrawId().subscribe(data => {
console.log('Result:: ', data);
});
And my service method:
getDrawId(): Observable<any> {
let gameObject;
return this.Game
.deployed()
.then(instance => {
gameObject = instance;
return gameObject.getDrawId.call();
})
.then(value => {
return value; //console.log(value) returns the data.
})
.catch(error => {
console.error('Error getting draw id; see log.');
console.log(error);
});
}
I am not sure how to get the data back from the service and to the calling component...
this.Game.deployed()is returning a promise (with.thens and.catches), but then you say the return type is anObservable<any>and try to use it as an observable.