I am trying to simply display weather details in my weather app, but I'm not able to access API response. This is what I tried so far:
In my service.ts
apiCall(): Observable<any> {
const rec = new HttpRequest(
'GET',
'https://api.openweathermap.org/data/2.5/onecall?lat=41,9109&lon=12'
);
return this.http.request(rec);
}
In my component.ts
ngOnInit(): void {
this.api.apiCall().subscribe((data) => {
this.response = data.body;
console.log(this.response)
});
}
In my html
<div>
<p>{{ response["current"]["humidity"] }}</p>
</div>
It actually does show the info, but I have to reload the app to make it update, which is not the point of an observable.
