How to avoid multiple http requests when same component is used twice in template
https://stackblitz.com/edit/angular-8sgrgz
hello component is used twice in the template and its making calling service method for http data
return this.http
.get('https://api.openweathermap.org/data/2.5/weather?
q=London&appid=517c7bbf790248290ad52d57725c4d5f')
.map((res) => {return res.json()})
.catch((error:any) =>
Observable.throw(error.json().error || 'Server
error')).share();}
the http request should happen only once
but its happening more than once