Open gitwithsarthak opened 3 years ago
facing these issues at the homeScreen.js
`import React, { useEffect, useState } from 'react'; import axios from 'axios'; import Product from '../components/Product'; import LoadingBox from '../components/LoadingBox'; import MessageBox from '../components/MessageBox';
export default function HomeScreen() { const [products, setProducts] = useState([]); const [loading, setLoading] = useState(false); const [error, setError] = useState(false); useEffect(() => { const fecthData = async () => { try { setLoading(true); const { data } = await axios.get('/api/products'); setLoading(false); setProducts(data); } catch (err) { setError(err.message); setLoading(false); } }; fecthData(); }, []); return (
); } `
Im getting the same error.
facing these issues at the homeScreen.js
`import React, { useEffect, useState } from 'react'; import axios from 'axios'; import Product from '../components/Product'; import LoadingBox from '../components/LoadingBox'; import MessageBox from '../components/MessageBox';
export default function HomeScreen() { const [products, setProducts] = useState([]); const [loading, setLoading] = useState(false); const [error, setError] = useState(false); useEffect(() => { const fecthData = async () => { try { setLoading(true); const { data } = await axios.get('/api/products'); setLoading(false); setProducts(data); } catch (err) { setError(err.message); setLoading(false); } }; fecthData(); }, []); return (
); } `