vinender singh
vinender singh

Reputation: 379

why my map function is not working to display API data on browser?

I am getting the data in console but, unable to find the correct path to map over data in nested map functions. I want an Image component for every product in array. API data in console

I am trying this path to map over object given below in picture.
This is the query having async function that fetched the data.

   const res = useCategoriesQuery({
     type: query.type,
     text: query?.text,
     category: query?.category,
      });
     console.log(res);

Map function

The Error I am getting is - Error

Upvotes: 0

Views: 661

Answers (1)

Bhojendra Rauniyar
Bhojendra Rauniyar

Reputation: 85575

You have to map over the data:

res.data?.categories.data.map()

Upvotes: 3

Related Questions