Having trouble retrieving the data from my service.
Working with Angular 8
.
Here's the code snippet:
Within the service:
query(url: string) {
this.subscription = this.socket$.subscribe(
(message) => {
return message;
},
(err) => {
return err;
},
() => console.warn('Completed!')
);
}
Inside the component:
Attempted methods:
fetchDataFromService() {
var result = this.myservice.query(myurl);
}
The result above returns undefined.
Also tried:
fetchDataFromService() {
this.myservice.connect(myurl).subscribe
}
However, 'subscribe' is throwing this error:
Property 'subscribe' does not exist on type 'void'.ts(2339)
Is there a way to get the service result without utilizing a promise
?