Reputation: 11
I want to fetch this data from rest api but when i tried to console.log(response) i am getting undefined value. what should i do ? api is sending data and i have checked it in my network tab in developer tool.
getProductList() : Observable<Product[]>{
return this.httpClient.get<GetResponse>(this.baseUrl).pipe(
map(response => response._embedded.products),
tap((response) => console.log("Response:"+response))
);
}
interface GetResponse{
_embedded:{
products: Product[];
}
}
Upvotes: 0
Views: 908
Reputation: 222522
You probably need to access Product?
map(response => response._embedded.product)
and interface
interface GetResponse{
_embedded:{
product: Product[];
}
}
Upvotes: 1