I want to display the list of products in a webPage but I am getting an error. I am using the async/await method on the axios.
The code:
const [products, setProducts] = useState([]);
useEffect(() => {
const fetchProducts = async () => {
const { data } = await axios.get("/api/products");
setProducts(data);
};
fetchProducts();
}, []);
I have installed cors and set the proxy as well in the front-end side package.json file but still getting an error like following:
