1function myApp() {
2 const [data, setdata] = useState()
3
4 useEffect(() => {
5 async function fetchMyAPI() {
6 const response = await fetch('api/data')
7 response = await response.json()
8 setdata(response)
9 }
10
11 fetchMyAPI()
12 }, [])
13}
1 useEffect(() => {
2 (async () => {
3 const products = await api.index()
4 setFilteredProducts(products)
5 setProducts(products)
6 })()
7 }, [])
8
9