So in my angular project i created a service which contains a method with http get request as follows:
  getAllProducts(){
return this.http.get<IProduct[]>(this.baseUrl + 'products/all');}
In another component I want to get the IProduct[] array using the service. So inside the component I have
ngOnInit(): void {
   
    this.update();
  }
  update(): void{
    this.adminService.getAllProducts().subscribe(response =>
      {
       this.allProducts = {...response};
       console.log(this.allProducts); //Returns a filled array
      }, error => {
        console.log(error);
      });
    console.log(this.allProducts); //Returns undefined
  }
My question is: How can I copy the httpget result into my component's variable and dont loose it outside the observable scope?
 
    