This question may seem simple, but I'm having trouble figuring it out.
Here is the code snippet I am working with:
getInstabul(): void {
this.homeService.getWeather()
.subscribe((weather) => {
this.instanbulWeathers = weather
// console.log(this.instanbulWeathers);
});
Within my service, I have the following code:
getWeather(): Observable<any>{
return this.http.get<any>(this.getWeatherUrl())
.pipe(
tap(weather => console.log(weather || 'not working')),
catchError(this.handleError('getWeather', []))
// this.getWeatherDetails();
);
After running the code, it returns the following response:
[…]
0: Object { title: "Istanbul", location_type: "City", woeid: 2344116, … }
length: 1
<prototype>: Array []
However, when attempting to access [weather.title], no value is displayed in the console. I need to retrieve this value to pass to another function within the component.
If anyone could provide assistance, especially since I am new to Angular, it would be greatly appreciated.