I am developing a React app where I have to load data from the server on the home page. It takes a small amount of time when loading data from the server. I want to display a spinner when the fetch api is called. I already created a spinner component, but I don't know how to display that spinner when the fetch api is triggered.
const [product,setProduct]=useState({});
useEffect(()=>{
fetch(`http://localhost:5000/readSingleCarsData/${id}`)
.then(res=>res.json())
.then(data=> {
setProduct(data)
setQuantity(data.quantity)
});
},[])