I have this service in IONIC 5 :
import { HttpClient } from '@angular/common/http';
.
.
.
getPlaces(placeId: string) {
return this.httpClient.get(
`https://test.com/offered-place/${placeId}.json`)
}
.
.
.
In my component when i try to call may service's function and subscribe to it:
this.myService.getPlaces().subscribe(()=>{})...
I got the error : TypeError: Cannot read property 'subscribe' of undefined.
but when I try to subscribe within the service it works !!
ps:
- IONIC 5
my service is injected in the constructor of my component (where I got my error)
my service is annotated :
@Injectable({ providedIn: 'root' })
- IDE Visual Code
Thanks in advance