I am following a YT MERN stack tutorial did exactly the same as the yt instructor
getting this error
its
Uncaught (in promise) SyntaxError: Unexpected token ‘<’, "<!DOCTYPE "… is not valid JSON
My home.js file
import { useEffect, useState } from "react"
// components
import ProductDetails from "../components/ProductDetails"
const Home = () => {
const [products, setProducts] = useState(null)
useEffect(() => {
const fetchProducts = async () => {
const response = await fetch('api/product/')
const json = await response.json()
console.log(response.ok)
if (response.ok) {
setProducts(json)
}
}
fetchProducts()
}, [])
return (
<div className="home">
<div className="products">
{products && products.map((product) => (
<ProductDetails key={product._id} product={product} />
))}
</div>
</div>
)
}
export default Home