I am using a service to fetch the products from woocommerce. In the constructor of the service, I make an HTTP get call which fetches products and subscribe to the local data variable.Then I created a function getData() in the service which returns this fetched data to myPage. Then from myPage, I make a call to the getData() function from the constructor of my Component page and assign it to the local products array.
The problem is that when my page gets loaded initially the data is not yet received/subscribed by the HTTP get call inside my service constructor so the getData() function call returns null array and I have to reload the component page manually after the data have been received in the service to get the data in my page.
Any idea what I am doing wrong here? and possible solution for that.