0

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[];
    }
}

JSON Data Format

1 Answer 1

1

You probably need to access Product?

map(response => response._embedded.product)

and interface

interface GetResponse{
    _embedded:{
      product: Product[];
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.