622 viewsMern Amazona

import { useEffect, useState } from “react”;
import { Link } from “react-router-dom”;
// import data from “../data”;
import axios from “axios”;
function HomeScreen() {
  const [products, setProducts] = useState([]);
  useEffect(() => {
    const fetchData = async () => {
      const result = await axios.get(“/api/products”);
      setProducts(result.data);
    };
    fetchData();
  }, []);
  return (
    <div>
      <h1>Jasa Modifikasi Pakaian</h1>
      <div className=’products’>
        {products.map((product) => (
          <div className=’product’ key={product.slug}>
            <Link to={`/product/${product.slug}`}>
              <img src={product.image} alt={product.name} />
            </Link>
            <div className=’product-info’>
              <Link to={`/product/${product.name}`}>
                <p>{product.name}</p>
              </Link>
              <p>
                <strong>${product.price}</strong>
              </p>
              <button>add to card</button>
            </div>
          </div>
        ))}
      </div>
    </div>
  );
}
export default HomeScreen;

whats wrong?

Bassir Answered question September 11, 2023

hello there,

What is the error message?

send it over discord channel here to get the solution here: https://discord.gg/EXCUcAH9

Bassir Answered question September 11, 2023
You are viewing 1 out of 2 answers, click here to view all answers.