my code .
import React from 'react'
import { useSelector } from 'react-redux';
export default function ProductDetail() {
const product = useSelector((state)=>state)
const datas = product.allProducts.products.Data
console.log('data',datas )
return (
)
}
this code executed correctly and gave correct output.. but i want const datas = product.allProducts.products.Data.category
when i try to get category data its shows error like Uncaught TypeError: Cannot read properties of undefined (reading ‘category’) .
my json data
"Data": {
"banner": [
{
"BannerId": 1,
"BannerImage": "image 10_1650873105.png",
"BannerTitle": "product banner1",
"BannerDescr": "The products with 50% offer1"
}
],
"category": [
{
"CatId": 23,
"CatName": "laptop",
"CatImage": "kari-shea-1SAnrIxw5OY-unsplash_1650877809.jpg"
}
]
}