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
It's strange, don't give error if you write
GetPortfolio(portfolioId: string): Observable {
return this.http.get('....', {
headers: new HttpHeaders(
{
'Content-Type': 'application/json',
})
});
}
It's look like, the compiler expect an object with the properites headers,params,observe..., but as your object have no type, the compiler can accept it
even you can do
headers: HttpHeaders = new HttpHeaders({
'Content-Type': 'application/json',
})
GetPortfolio(portfolioId: string): Observable {
return this.http.get('...', {
headers: this.headers
})
}