0
0 Comments

best regards

my code HomeScreen.js is :

import { useEffect, useState } from ‘react’;
import { Link } from ‘react-router-dom’;
import axios from ‘axios’;
// import data from ‘../data’;

function HomeScreen() {

const [producto, setProducts] = useState([]);
useEffect(() => {
const fetchData = async () => {
const result = await axios.get(‘/api/products’);
setProducts(result.data);
};
fetchData();
}, []);
return (

Featured Products

{producto.map((product) => (

{product.name}

${product.price}

Add to cart

))}

);
}
export default HomeScreen;

thanks

Bassir Changed status to publish October 14, 2022