I 'm new in react and I want to render my products data that I fetch from api. I'm using the map function to show the data I get from the api on the screen. But the following error appears in the console .There is no problem with the data, I can see that it is drawn from the api as console result, but it does not print on the screen in the form of a table, I think it will probably work if I solve the .map function problem. What can be the problem .Have you ever faced this problem ?
ERRORS
ProductList.js:27 Uncaught TypeError: products.map is not a function
The above error occurred in the <ProductList> component:
My ProductList
import { ProductContext } from '../Contexts/ProductContext';
import React, { useContext } from 'react';
import Product from './Product'
export default function ProductList() {
const { products } = useContext(ProductContext);
return (
<>
<div>
<table className='table table-striped table-hover'>
<thead>
<tr>
<th>Product ID</th>
<th>product is offerable</th>
<th>Product Name</th>
<th>Product Description</th>
<th>Product is sold</th>
<th>Category ID</th>
</tr>
</thead>
<tbody>
<div>
{products.map((product) => (
<tr>
<td>{product.productId}</td>
<td>{String(product.isOfferable)}</td>
<td>{product.productName}</td>
<td>{product.productDescription}</td>
<td>{String(product.isSold)}</td>
<td>{product.categoryName}</td>
</tr>
))}
</div>
</tbody>
</table>
</div>
</>
)
}
MY API DATA FROM POSTMAN
{
"data": [
{
"categoryId": 1,
"productId": 1,
"productName": "Bilgisayar",
"categoryName": "Yazılım",
"colorName": "gri",
"price": 15000,
"brandName": "ASUS",
"isOfferable": false,
"isSold": false
}, // example data. it continues like this
products.data.map(...).