Angular HttpClient return expecting observable rather than observable

前端 未结 4 871
温柔的废话
温柔的废话 2020-12-08 14:54

I\'m getting a compilation error on the return type when using HttpClient. In my function GetPortfolio, I\'m expecting the GET call to return the j

4条回答
  •  自闭症患者
    2020-12-08 15:34

    As this is a service 'PortfolioService' we may not need interface here, instead we can use of type any, and also GET method is only necessary here.

    GetPortfolio(portfolioId): Observable {
      return this.http.get(this.apiUrl + '/${portfolioId}')
             .map((response:any) => {
                  return response;
             });
    }
    

    This should work, please try.

提交回复
热议问题