import React, { useState, useEffect, useRef } from 'react'; import { Link } from 'react-router-dom'; import ListCard from '../Components/ListCard'; import axios from 'axios'; import catchError from '../utils/catchErrors'; import { Container, Row } from 'react-bootstrap'; function Home() { const INIT_PRODUCT = { bestProduct: [], newProduct: [], } const [productlist, setProductlist] = useState(INIT_PRODUCT) const [error, setError] = useState('') useEffect(() => { getProductlist() }, []) async function getProductlist() { try { const response = await axios.get(`/api/product/getproduct`) setProductlist({ bestProduct: response.data.bestProduct, newProduct: response.data.newProduct }) } catch (error) { catchError(error, setError) } } return (

Best

{productlist.bestProduct.map(pro => ( ))}

New Arrival

{productlist.newProduct.map(pro => ( ))}
) } export default Home