I am having issues getting the data returned from my service.
I'm using Angular 8
.
Here is the code:
In the service
callit(url: string) {
this.subscription = this.socket$.subscribe(
(message) => {
return message;
},
(err) => {
return err;
},
() => console.warn('Completed!')
);
}
In the component.
I've tried:
getResultFromService() {
var res = this.myservice.callit(myurl);
}
The above res says undefined.
I've tried:
getResultFromService() {
this.myservice.connect(myurl).subscribe
}
But subscribe is giving me this error:
Property 'subscribe' does not exist on type 'void'.ts(2339)
How can I get the result from the service return without using a promise
?