I'm getting this error in my react project
./src/components/HomePage.js
Module not found: Can't resolve 'axios' in 'C:\Users\Admin\Desktop\fcwShp-ft\frontend\src\components'
My code:
import React, { useState, useEffect } from 'react';
import { Link } from 'react-router-dom';
import axios from 'axios';
const HomePage = () => {
const [products, setProduct] = useSatate([]);
useEffect(() => {
const fetchData = async () => {
const { data } = await axios.get("/api/products");
setProduct(data);
}
return () => {
};
}, [])
return (
<ul className="products">
{
products.map(product =>
<li className="liProp">
<div className="product">
<Link to={"/product/" + product._id}>
<img className="product-image" src={product.image} alt="product" />
</Link>
<div className="product-name">
<Link to={"/product/" + product._id}>{product.name}</Link>
</div>
<div className="product-brand">{product.brand}</div>
<div className="product-price">$ {product.price}</div>
<div className="product-rating">{product.rating} Stars ({product.numReviews} Reviews)</div>
</div>
</li>
)
}
</ul>
)
}
export default HomePage;
Maybe someone has solved the same problem (i hope) and can help?
Also tried answers in this thread but nothing helped
Was trying npm install axios && npm install --save axios